- 分享
- 0
- 人气
- 0
- 主题
- 3
- 帖子
- 205
- UID
- 84237
- 积分
- 312
- 阅读权限
- 15
- 注册时间
- 2007-6-25
- 最后登录
- 2015-12-29
- 在线时间
- 596 小时
|
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{ char choice,ch;
int a,b,c;
int answer;
b=0;
c=100;
srand(time(NULL));
s3: answer =(rand()%100)+1;
s1:
printf("Press Y to start Game,Press N to Quit\n");
scanf("%c",&choice);
if(choice=='y'){printf("Start Game!\n");
printf("enter a number 1~100,0 to Quit\n");
s2: scanf("%d",&a);
if (a<b){
printf("enter number between %d and %d:\n",b,c);
goto s2;
}
else if(a>c){
printf("enter number between %d and %d:\n",b,c);
goto s2;
}
if(a==0)
return 0;
else if(a<=-1||a>100){
printf("Cant enter a number less than 0 and more than 100....");
goto s2;
}
else {
printf("Wrong number!Guess Again!\n");
if(a==answer)
{a==answer;
printf("Correct!Do you want to play again?Y or N\n");
scanf("%c",&ch);
if(ch=='Y')
goto s3;
else if(ch=='N'){
printf("Goodbye\n");
}
}
else if(a<answer)
{b=a;
printf("enter number between %d and %d:\n",b,c);
goto s2;
}
else if(a>answer)
{c=a;
printf("enter number between %d and %d:\n",b,c);
goto s2;
}
}
}
else {printf("Goodbye!");
return 0;
}
}
想请问下,为什么当我执行的时候,答案对了就直接关闭程序的??
请问我哪里出现问题了啊?
[ 本帖最后由 fuiyooo 于 2009-4-19 10:21 PM 编辑 ] |
|