码迷,mamicode.com
首页 > 其他好文 > 详细

7-24 猜数字游戏

时间:2019-12-12 12:52:32      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:bing   col   lse   too   return   png   break   猜数字游戏   ima   

技术图片

 1 #include <stdio.h>
 2 
 3 int main(void)
 4 {
 5     int magic_number, n;
 6     int guess_number;
 7     int count = 0;
 8 
 9     scanf("%d %d", &magic_number, &n);
10 
11     do
12     {
13         scanf("%d", &guess_number);
14         if (guess_number < 0)
15         {
16             printf("Game Over\n");
17             break;
18         }
19 
20         count++;
21         if (guess_number > magic_number)
22         {
23             printf("Too big\n");
24         }
25         else if (guess_number < magic_number)
26         {
27             printf("Too small\n");
28         }
29         else
30         {
31             if (count == 1)
32             {
33                 printf("Bingo!\n");
34             }
35             else if (count <= 3)
36             {
37                 printf("Lucky You!\n");
38             }
39             else
40             {
41                 printf("Good Guess!\n");
42             }
43             break;
44         }
45 
46     } while (count < n);
47 
48     if (count == n && magic_number != guess_number)
49     {
50         printf("Game Over\n");
51     }
52 
53     return 0;
54 }

 

7-24 猜数字游戏

标签:bing   col   lse   too   return   png   break   猜数字游戏   ima   

原文地址:https://www.cnblogs.com/2018jason/p/12028322.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!