需求:
1、用户先输入一个数
2、系统生成一个1-100的随机数
3、比较用户输入的数字与随机数
4、根据比较的结果输出相应的内容提示
5、用户再次输入,直到猜对为止
6、退出游戏
#include#include #include using namespace std; int main() { int score = 0; cout << "please input your score: "; srand((unsigned int)time(NULL)); int num = rand() % 100 + 1; while (1) { cin >> score; if (score > num) { cout << "your guess is too high!" << endl; } else if (score < num) { cout << "your guess is too low!" << endl; } else { cout << "bingo!"; break; } } system("pause"); return 0; }



