7-24 猜数字游戏
Posted 2018jason
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了7-24 猜数字游戏相关的知识,希望对你有一定的参考价值。
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 "); 17 break; 18 } 19 20 count++; 21 if (guess_number > magic_number) 22 { 23 printf("Too big "); 24 } 25 else if (guess_number < magic_number) 26 { 27 printf("Too small "); 28 } 29 else 30 { 31 if (count == 1) 32 { 33 printf("Bingo! "); 34 } 35 else if (count <= 3) 36 { 37 printf("Lucky You! "); 38 } 39 else 40 { 41 printf("Good Guess! "); 42 } 43 break; 44 } 45 46 } while (count < n); 47 48 if (count == n && magic_number != guess_number) 49 { 50 printf("Game Over "); 51 } 52 53 return 0; 54 }
以上是关于7-24 猜数字游戏的主要内容,如果未能解决你的问题,请参考以下文章