#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main(int argc, char** argv) { srand(time(0)); cout<<"输入做题数量"; int b,c; double m,a,sum=0; cin>>a; for(int i=1;i<=a;i++){ int x=rand()%100; int y=rand()%100; cout<<x<<"+"<<y<<"="; cin>>b; c=x+y; if(b==c){ cout<<"恭喜你!答对了"<<endl; sum++; }else{ cout<<"很遗憾,没答对"<<endl; sum--; } } m=sum/a*100; cout<<"你的正确率为:"<<m<<"%"<<endl; if(sum>=a*0.9){ cout<<"优秀"<<endl; }else if(sum==a*0.6){ cout<<"及格"<<endl; }else if(sum<a*0.6){ cout<<"不及格"<<endl; } cout<<"一共"<<a<<"题,你得了"<<sum<<"分"<<endl; return 0; }
标签:cout,以内,int,加法,100,include From: https://www.cnblogs.com/fushuxuan/p/17398010.html