#include <iostream>
#include<string>
#include<ctime>
using namespace std;
int main(){
//添加随机种子,利用当前系统时间生成随机数,防止每次随机数都一样
srand((unsigned int)time(NULL));
//系统生成随机数
int num = rand() % 100 + 1;
int x = 0;
cout << "Enter:" << endl;
while (1) {
cin >> x;
if (x > num) {
cout << "大了" << endl;
}
else if (x < num) {
cout << "小了" << endl;
}
else {
cout << "对了" << endl;
break;
}
}
system("pause");
return 0;
}
C++:猜数字游戏
最新推荐文章于 2022-09-09 16:46:26 发布