数字相加

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
	srand(time(0));
	int a;
	int b;
	double c,d,e=0;

	cout<<"请输入你要做的题数"<<endl;
	cin>>c;
	
	for(int i=0;i<c;i++){
		a=rand()%40+rand()%40+rand()%40;
		b=rand()%40+rand()%40+rand()%40;
		cout<<a<<"+"<<b<<"=?"<<endl;
		cin>>d;
		if(a+b==d){
			cout<<"恭喜你,答对了,加1分"<<endl;
			e++;
		}else{
			cout<<"可惜,你答错了,加0分"<<endl;
		}
	}
	cout<<"你答了"<<c<<"道题,"<<"你答对了"<<e<<"道题,得了"<<e<<"分"<<endl;
		double f=e/c*100;
	cout<<"正确率是"<<f<<"%"<<endl;
	if(c>=4){
		if(e/c*100>=0.8){
			cout<<"优秀"<<endl;
		}else{
			cout<<"继续努力"<<endl;
		}
	}else{
			cout<<"继续努力"<<endl;
		}
	return 0;
}

  

posted @ 2023-05-13 19:25  陈若麟  阅读(167)  评论(0编辑  收藏  举报