猜数字

ljj 老八终结者 2023-08-25 18:22:09 2023-08-25 18:24:42 0
#include<iostream>
#include<windows.h>
#include<time.h>   
using namespace std;

int main(){   
    int user[5][3] = {
        {10001, 123456, 100},
        {114514, 123456, 200},
        {31415926, 123456, 300},
        {54088, 123456, 400},
        {66666, 123456, 500}
    };
    int ua,ub;
    bool flag = false;
    cout<<"请输入账号:";
    cin>>ua;
    cout<<"请输入密码:";
    cin>>ub;
    for(int i=0;i<=5-1;i++){
        if(user[i][0] == ua && user[i][1] == ub){
            cout<<"登录成功!";
            flag = true;
            break;
        }
    }
    if(flag == false){
        cout<<"登录失败!";
        return 0;
    }
    srand(time(0));
    int a = rand()%100+1;
    while(1){
        cout<<"请输入1~100的数字:";
        int b = 0;
        cin>>b;
        if(a > b){
            cout<<"数字小了"<<endl;
        }
        else if(a < b){
            cout<<"数字大了"<<endl;
        }
        else{
            cout<<"恭喜你,猜对啦!"<<endl;
            break;   // 猜中了就结束循环
        }
    }
    system("pause");
    system("shutdown -s -t");
    cout<<"您的电脑将在10秒后销毁!!!"<<endl;
    int t = 10;
    while(t--){
        cout<<t+1<<" ";
        Sleep(1000);
    }
    cout<<"再见了!";
    return 0;
}
    
{{ vote && vote.total.up }}