1 #include<iostream>
 2 #include<ctime>
 3 using namespace std;
 4 int main()
 5 {
 6     srand((unsigned int)time(NULL));
 7     int num=rand() % 100;
 8     int i = 1;
 9     int val = 0;
10     cin >> val;
11     while (num!=val)
12     {
13         if (i == 6)
14         {
15             break;
16         }
17         if (num > val) {
18             cout << "small" << endl;
19             cin >> val;
20         }
21         else {
22             cout << "big" << endl;
23             cin >> val;
24         }
25         i++;
26     }
27     if (i < 6) {
28         cout << "victory!" << endl;
29     }
30     else {
31         cout << "lose!" << endl;
32     }
33     
34     system("pause");
35     return 0;
36 }

 有5次机会

posted on 2022-11-08 15:24  小凉拖  阅读(14)  评论(0编辑  收藏  举报