博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1,实现在线答题 2,答题结束后可以判断对错 3,并将错题的结果保存起来。...
阅读量:4560 次
发布时间:2019-06-08

本文共 870 字,大约阅读时间需要 2 分钟。

#include<iostream>

#define HOW 10
using namespace std;

char get_oper(int n)

{
switch(n)
{
 case 0:return '+';
 case 1:return '-';
 case 2:return '*';
 case 3:return '/';
}
}

int main()

{
int num1=0,num2=0,count=0;
float user_answer=0,right_answer=0;
int operators=0; //0:+ 1:- 2:* 3:/

for(int i=1;i<=HOW;i++)

{
     num1=rand();
 num2=rand();
 operators=rand()%4;

 if(operators==3)num1=num2*(rand()%100);

 

 cout<<i<<":? "<<num1<<get_oper(operators)<<num2<<"=";
 cin>>user_answer;

 switch(operators)
 {
 case 0:right_answer=num1+num2;break;
 case 1:right_answer=num1-num2;break;
 case 2:right_answer=num1*num2;break;
 case 3:right_answer=num1/num2;
 }

 

 if(right_answer==user_answer)
 {
 cout<<"RIGHT"<<endl;
 count++;
 }
 else
 cout<<"WRONG"<<endl;
}

cout<<"Right:"<<count<<"? Wrong:"<<HOW-count<<""<<count<<"/"<<HOW<<"="<<count/HOW;

return 0;

}

转载于:https://www.cnblogs.com/L20160909/p/9885441.html

你可能感兴趣的文章
Codeforces Round #370 (Div. 2)(简单逻辑,比较水)
查看>>
操作系统进程调度算法
查看>>
less与sass的区别点
查看>>
event.keycode值大全
查看>>
array and ram
查看>>
工作笔记——禁用浏览器的返回按钮
查看>>
免费获得盛大网盘EverBox125G容量方法
查看>>
如何用spidermonkey在python里调用javascript代码
查看>>
2016级算法第一次练习赛-A.群鸦的盛宴
查看>>
浅谈深度学习和本体间的关系
查看>>
js下载文件
查看>>
python 中的高级函数filter()
查看>>
vim配置
查看>>
python创建系统时间字符串
查看>>
服务器上产看报错的日志的方法
查看>>
软件安装
查看>>
黑盒测试实践—第四天
查看>>
luogu P4448 [AHOI2018初中组]球球的排列
查看>>
win7每天出现taskeng.exe进程的解决方案
查看>>
React Children
查看>>