- 分享
- 0
- 人气
- 0
- 主题
- 1
- 帖子
- 84
- UID
- 15778
- 积分
- 178
- 阅读权限
- 13
- 注册时间
- 2005-8-3
- 最后登录
- 2014-9-2
- 在线时间
- 2954 小时
|
#include<stdio.h>
#include<stdlib.h>
int main(void)
{ char choice,ch;
int a,b,c;
int answer;
b=0;
c=100;
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==0) return 0;
else if(a<=-1||a>100)goto s2;
s4: if(a==answer)
{printf("Correct!Do you want to play again?Y or N\n");
scanf("%c",&ch);
switch(ch)
{case 'y':goto s3;
case 'n':printf("Goodbye\n");break;
default :printf("Not available\n");goto s4;}}
else {
printf("Wrong number!Guess Again!\n");
if(a<answer)
{b=a;
printf("enter number between %d and %d",b,c);goto s2;}
if(a>answer)
{c=a;
printf("enter number between %d and %d",b,c);goto s2;
}
};}
else {printf("Goodbye!");
return 0;
}
}
fuiyoo...这样应该可以了...我修改了一点...看重点就好了
[ 本帖最后由 冥 于 2009-4-18 07:55 PM 编辑 ] |
|