C++猜数字小游戏。

ljc12 2023-08-25 17:44:11 2023-08-25 18:22:21 2
#include <iostream>
#include <windows.h>
#include <time.h>
using namespace std;
 
int main() {
	srand(time(0));
	int a = rand()%100+1 ;


	while(1){
		cout<<"请输入1~100的数字:"<<endl;
		int b=0;
		cin>>b;
		if(a>b){
			cout<<"数字小了"<<endl;
		}
		else if(a<b){
			cout<<"数字大了"<<endl;
		}
		else {
			cout<<"恭喜你,猜对了,大聪明"<<endl;
			break;
		} 		 
	}
	cout<<"您的电脑将在10秒后关机"<<endl;
	int t=10;
	while(t--){
		cout<<t+1<<endl;
		Sleep(1000);
	
	}
	cout<<"BooG ! ! !";
    return 0;
}
{{ vote && vote.total.up }}