zoukankan      html  css  js  c++  java
  • [刷题] PTA 7-24 猜数字游戏

    程序:

     1 #include <stdio.h>
     2 int main()
     3 {
     4     int num, times;
     5     scanf("%d %d", &num,&times);
     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 }

     主要考察循环和判断

  • 相关阅读:
    gflag使用
    INTERVIEW #2
    Decision Tree
    Java FAQ
    K-Nearest Neighbors
    INTERVIEW #1
    C++ FAQ
    INTERVIEW #0
    Selection Sort
    TCP 3-Way Handshake
  • 原文地址:https://www.cnblogs.com/cxc1357/p/10658861.html
Copyright © 2011-2022 走看看