随机数

#include <bits/stdc++.h> 
#include <ctime>
using namespace std;
int main(int argc, char** argv) {
    /*
    while(1){
        srand(time(0));
        int a;
        cin>>a;
        int b=rand()%5+1;
        if(a==b){
            cout<<"恭喜你中奖了" <<endl;
        }
        else{
            cout<<"你没中奖,正确答案是"<<b;
        }
    }*/
    int d,e,f=0;
    int a,b,c;
    cout<<"请输入你想做的题数"<<endl;
    cin>>d;
    for(int i=0;i<d;i++){
        
        srand(time(0));
        a=rand()%90+10;
        b=rand()%90+10;
        c=a+b;
        cout<<a<<"+"<<b<<"="<<endl; 
        cout<<"请输入你认为的答案"<<endl;
        cin>>e;
        if(e==c){
            cout<<"恭喜你回答正确,加1分"<<endl; 
            f++;
        }else{
            cout<<"答错了,下一题"<<endl; 
        }
    }

    if(f/d>=0.9){
        cout<<"优秀"<<endl; 
    }else if(f/d>=0.6){
        cout<<"勉勉强强"<<endl;
    }else{
        cout<<"再练练"<<endl; 
        
    }
    

    
    return 0;
}

 

posted @ 2023-05-13 19:20  郭立恒  阅读(19)  评论(0)    收藏  举报