- 分享
- 0
- 人气
- 0
- 主题
- 1
- 帖子
- 84
- UID
- 15778
- 积分
- 178
- 阅读权限
- 13
- 注册时间
- 2005-8-3
- 最后登录
- 2014-9-2
- 在线时间
- 2954 小时
|
#define _CRT_SECURE_NO_DEPRECATE \\当中有scanf的问题,所以用这个去弄掉scanf的warning
#include<stdio.h>
#include<stdlib.h>
int main(void)
{ char choice,ch;
int a;
int answer;
s3: answer =(rand()%100)+1;
s1:
printf(" Press Y to start Game,Press N to Quit\n");
scanf("%c",&choice);
switch(choice)
{
case 'y':printf("Start Game!\n");
s2: printf("enter a number 1~100,0 to Quit\n");
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");
goto s2;};
case 'n':printf("Goodbye!");break;
default :printf("not available\n");goto s1;
};
}
这个我自己打的...有什么问题...看看一下吧...作参考..
switch跟if的问题拿来对比...这样才会进步嘛...em0020
if的我也试过了...可以...em0020
[ 本帖最后由 冥 于 2009-4-18 06:56 PM 编辑 ] |
|