#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;
}
}
}
}
安卓的c语言猜生肖代码
最新推荐文章于 2024-07-25 20:21:49 发布