程序:
1 #include <stdio.h> 2 int main() 3 { 4 int num, times; 5 scanf("%d %d", &num,×); 6 7 int i = 0, guess; 8 while(i< times){ 9 scanf("%d", &guess); 10 if(guess < 0){ 11 printf("Game Over "); 12 break; 13 } 14 if(guess > num){ 15 printf("Too big "); 16 } 17 if(guess < num){ 18 printf("Too small "); 19 } 20 if(guess ==num){ 21 if(i == 0){ 22 printf("Bingo! "); 23 }else if(i < 3){ 24 printf("Lucky You! "); 25 } 26 else{ 27 printf("Good Guess! "); 28 } 29 break; 30 } 31 i++; 32 } 33 if(i>= times){ 34 printf("Game Over "); 35 } 36 }
主要考察循环和判断