|
5啊哈币
本帖最后由 初学C 于 2015-6-25 18:17 编辑
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <windows.h>
int main()
{
C:;
srand((unsigned)time(NULL));
int a = 1+rand()%6;
int b;
int c = 1;
char d;
printf("hi,兄弟,我打算和你一起玩猜数字的小游戏\n");
printf("你猜我会想个几?\nps:输入1~6之间的数字\n");
loop:;
printf("你猜=");
scanf("%d",&b);
if(b>6)
{
printf("你.........\n");
printf("沉默3秒后......\n");
printf("1\n");
Sleep(1000);
printf("2\n");
Sleep(1000);
printf("3\n");
Sleep(1000);
printf(".......是个天才,是个天生的蠢才\n");
goto hi;
}
if(b!=a)
{
if(b>a)
{
printf("老兄,猜大了,罚再猜一次!!!\n");
printf("3\n");
Sleep(1000);
printf("2\n");
Sleep(1000);
printf("1\n");
Sleep(1000);
c++;
goto loop;
}
if(b<a)
{
printf("老兄,猜大了,罚再猜一次!!!\n");
printf("3\n");
Sleep(1000);
printf("2\n");
Sleep(1000);
printf("1\n");
Sleep(1000);
c++;
goto loop;
}
}
if(b==a)
{
printf("老兄,猜中了!!!你共猜了%d次\n",c);
}
printf("答案就是");
printf("%d\n",a);
printf("再来一次?\n");
printf("ps:输入y或n\n");
scanf("%s",&d);
if(d=='y')
{
goto C;
}
hi:;
system("pause");
return 0;
}
为什么有时输入0还说猜大了呢???
|
最佳答案
查看完整内容
[mw_shl_code=c,true]if(b>a)
{
printf("老兄,猜大了,罚再猜一次!!!\n");
//……
goto loop;
}
if(b
|