Created
June 25, 2014 01:29
-
-
Save Alex-ZL/7a86579009c53df059e0 to your computer and use it in GitHub Desktop.
Just a C exercise, but failed to pass: http://pat.zju.edu.cn/submissions/488963
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(){ | |
int guess, answer, limit, count=1; | |
scanf("%d %d", &answer, &limit); | |
while (1){ | |
scanf("%d", &guess); | |
if (guess<0 || count>limit){ | |
printf("Game Over\n"); | |
break; | |
} | |
else if(guess==answer && count==1){ | |
printf("Bingo!\n"); | |
break; | |
} | |
else if(guess==answer && count<=3){ | |
printf("Lucky You!\n"); | |
break; | |
} | |
else if(guess==answer && count>3 && count<=limit){ | |
printf("Good Guess!\n"); | |
break; | |
} | |
else if(guess>answer){ | |
printf("Too big\n"); | |
} | |
else if(guess<answer){ | |
printf("Too Small\n"); | |
} | |
count++; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment