C语言程序逻辑求助。歇歇蟹蟹
程序代码:
#include <stdio.h> int main() { int i,mynumber=88,n,yournumber; printf("please input the biggest times you can input:\n"); scanf("%d",&n); printf("please input yournumber:\n"); scanf("%d",&yournumber); for(i=1;i<=n;i++) {if(yournumber<mynumber) {printf("too small!\nanother number you want to guess:\n"); scanf("%d",&yournumber);} else if(yournumber>mynumber) {printf("too bigger!\nanother number you want to guess:\n"); scanf("%d",&yournumber);} else if(yournumber=mynumber) { switch(i) { case 1:printf("Bingo!");break; case 2: case 3:printf("Lucy you!");break; } if(i>3) printf("good guess!");break; } } if(i>n) printf("game over!"); return 0; }输入一个允许猜测的最多次数n,再输入一个你所猜的整数yournumber,与被猜数mynumber(=88)进行比较,若相等,显示猜中的消息;若不等,
显示与被猜数的大小关系(too bigger 或 too small )最多猜n次。如果第1次就猜中,显示:“Bingo!”;如果是3次(含)以内猜中的,则显示“Lucky You!”,
如果是超过3次(n次以内)猜中的,显示“Good Guess!”;如果超过n次,则显示“Game Over”。我写的有点问题,猜错超过n也不显示game over,求高手解答。可以的话能不能提供别的程序进行参考。歇歇~