随机数——加法做题

#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,e;
    double c,d = 0;
    double f;
    cout<<"你想做几道题?";
    cin>>c;
    for(int i = 1;i<=c;i++){
        srand(time(0));
        a = rand()%90+10;
        b = rand()%90+10;
        cout<<a<<"+"<<b<<"=";
        cin>>e;
        if(a+b==e){
            d++;
            cout<<"恭喜你!!!答对一道题!!!得分+1分"<<endl;
        }else{
            cout<<"答错了,不加分,正确的答案是"<<a+b<<"加油!!!"<<endl;
        }
    }
    cout<<"你的总分是"<<d<<""<<endl<<"一共做对了"<<d<<"道题"<<endl;
    f = d/c;
    cout<<"正确率是"<<f*100<<"%"<<endl;
    if(d/c>=0.9){
        cout<<"优秀!!!";
    }else if(d/c>=0.5){
        cout<<"及格";
    }else{
        cout<<"再练练";
    }
    return 0;
}

 

posted @ 2023-05-13 19:23  王一行(小号)  阅读(15)  评论(0编辑  收藏  举报