Skip to content

Instantly share code, notes, and snippets.

@Alex-ZL
Created June 25, 2014 01:29
Show Gist options
  • Save Alex-ZL/7a86579009c53df059e0 to your computer and use it in GitHub Desktop.
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
#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