* Loop-20. Guess digital games

Source: Internet
Author: User
1/* 2 * Main. C 3 * C20-loop-20. guess the number game 4 * created on: August 18, 2014 5 * Author: the boomkeeper 6 ********** test section passed the *********** 7 */8 9 # include <stdio. h> 10 11 int main (void) {12 13 int random = 0, n = 0; // the random number entered by the system and the maximum number of guesses 14 int in = 0; // guess 15 int COUNT = 0 for each input; // count 16 17 scanf ("% I", & random, & N); 18 19 int I; 20 For (I = 0; I <n; I ++) {21 22 count ++; 23 24 scanf ("% d", & in ); 25 26 if (in <0) {27 printf ("% s \ n", "Game over"); 28} Else if (in! = Random) {29 If (in> random) 30 printf ("% s \ n", "too big"); 31 if (in <random) 32 printf ("% s \ n", "Too small"); 33} else if (in = random) {34 break; 35} 36} 37 38 If (COUNT = 1) {39 printf ("% s \ n", "Bingo! "); 40 return 0; 41} else if (count <= 3) {42 printf (" % s \ n "," Lucky you! "); 43 return 0; 44} else if (count <= N) {45 printf (" % s \ n "," Good guess! "); 46 Return 0; 47} 48 49 return 0; 50}

 

 

Question link:

Http://pat.zju.edu.cn/contests/basic-programming/%E5%BE%AA%E7%8E%AF-20

 

 

.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.