小学生算数能力系统
2016-06-13 20:11
190 查看
// // main.cpp // activity // // Created by 徐伟 on 6/13/16. // Copyright © 2016 fizz. All rights reserved. // #include <iostream> #include<ctime> #include<cstdlib> int qa(); //函数声明,完成一道题的测试并返回评判结果,正确1为,错误为0 using namespace std; int main() { int sum=0;//学生得分 for(int i=0; i<10; i++) { cout<<"第"<<i+1<<"题:"<<endl; sum+=qa(); cout<<endl; } cout<<"共答对了"<<sum<<"道题,得分"<<sum*10<<endl; return 0; } int qa() { srand(time(0)); //初始化随机种子 int a,b,c,d,t; a=rand()%100+1; b=rand()%100+1; c=rand()%4; if(a<b&&(c==1||c==3)) //给小学生的题,减和除运算保证大减小和大除以小(额外增加的需求,并非原题中提及) { d=a; a=b; b=d; } if(c==3)//对于除法,调整被除数,以保证能整除(额外增加的需求,并非原题中提及) a=(a/b)*b; switch(c) { case 0: d=a+b; cout<<a<<"+"<<b<<"="; break; case 1: d=a-b; cout<<a<<"—"<<b<<"="; break; case 2: d=a*b; cout<<a<<"×"<<b<<"="; break; case 3: d=a/b; cout<<a<<"÷"<<b<<"="; break; } cin>>t; if(t==d) cout<<" right! "; else cout<<" wrong! "; return t==d; }
相关文章推荐
- select value from v$diag_info where name='Default Trace File';
- 浅谈final、finally、finalize的区别
- spring data jpa 解释
- [Intellij IDEA]_eclipse项目导入
- select value from v$diag_info where name='Default Trace File';
- select value from v$diag_info where name='Default Trace File';
- 第15周程序阅读6
- 分布式数据库
- AJAX
- Solr优化案例分析
- 分布式与集群
- spark 1.6.1安装
- 猜数字游戏
- Android ViewPager的适配器PagerAdapter的一般写法
- 【Leetcode】355. Design Twitter
- ANR in an IntentService with its own process
- hdu 5444 继续二叉查找树
- 通过maven-shade-plugin 解决Elasticsearch与hbase的jar包冲突问题
- cpp的json的用法举例
- HDU 3465 线段树