#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
int main()
{
int number,g=1;
while(g)/利用g来判断是否继续进行游戏/
{
number=0;/比较次数置零/
for(;😉
{
char* a[12]={“鼠”,“牛”,“虎”,“兔”,“龙”,“蛇”,“马”,“羊”,“猴”,“鸡”,“狗”,“猪”};
char*b[1];
printf(“请输入生肖:\n”);
scanf("%s",&b[1]);
number++;/次数累加/
srand((unsigned)time(NULL));
if(a[rand()%12]<b[1])
printf(“Guess big猜大了!\n”);
else if(a[rand()%12]>b[1])
printf(“Guess it’s too small猜小了!\n”);
else
{
printf(“Guess right猜对了!\n”);
printf(“The number of guesses is猜测次数是:%d\n”,number);
printf(“Wanna continue想继续吗? 1.continue继续 0.exit退出\n”);
scanf("%d",&g);/选择是否继续/
break;
}
}
}
}
10-02
397
07-02
10-17
01-07
03-14
01-27
12-01
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交