#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main(int argc, char** argv) { int shuliang,n1,n2,x,s,m=0; cout<<"输入你要做的题的数量\n"; cin>>shuliang; for(int i=0;i<shuliang;i++){ srand(time(0)); n1=rand()%100; n2=rand()%100; cout<<n1<<"+"<<n2<<"=?"<<endl; x=n1+n2; cin>>s; if(s==x){ cout<<"正确"<<endl<<endl; m+=1; }else{ cout<<"错误"<<endl<<endl; } } cout<<"共"<<shuliang<<"道题"<<"你做对了"<<m<<"道题"<<endl; if(m==shuliang){ cout<<"太腻害了,全对了!"; }else if(m>=shuliang*0.8){ cout<<"不错呦"; }else if(m>=shuliang*0.6&&m<shuliang*0.8){ cout<<"一般"; }else if(m<shuliang*0.6){ cout<<"不及格哦"; } return 0; }
标签:运算,int,随机数,加法,include,shuliang,cout From: https://www.cnblogs.com/wangyueshuo/p/17397991.html