修练者
#include<iostream>
#include<windows.h>
#include<ctime>
#include<cstdlib>
using namespace std;
int n,a,b,c,d,e,cnt;
int main(){
system("color f1");
cout<<" 计算小游戏 \n";
cout<<"本人第二次做这种代码,做的可能不好,我会改进的!!!\n";
Sleep(1500);
cout<<"请输入答题次数:";
cin>>n;
for(int i=1;i<=n;i++){
cout<<"第"<<i<<"题/共"<<n<<"题:\n";
srand(time(0));
a=rand()%100+1;
b=rand()%100+1;
c=rand()%100+1;
if(c%4==0){
cout<<a<<"+"<<b<<"=";
d=a+b;
}
else if(c%4==1){
cout<<max(a,b)<<"-"<<min(a,b)<<"=";
d=max(a,b)-min(a,b);
}
else if(c%4==2){
cout<<a<<"*"<<b<<"=";
d=a*b;
}
else{
cout<<max(a,b)<<"/"<<min(a,b)<<"(直接输入a除b的商,不用输入a除b的余数)=";
d=(int)(max(a,b)/min(a,b));
}
cin>>e;
if(e==d){
cout<<"答对了!!!";
cnt++;
}
if(e!=d){
cout<<"答错了,正确答案是:"<<d;
}
Sleep(1500);
system("cls");
}
system("color f2");
cout<<"总共有"<<n<<"道题,你做对了"<<cnt<<"道题";
return 0;
}
你们给点儿建议,我会采纳!!!