<span style="font-size:18px;">#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main()
{
int a = 1;
while(1)
{</span>
<span style="font-size:18px;">printf("******请选择******\n");
printf("******1.play******\n");
printf("******0.exit******\n");
scanf("%d\n",&a);
switch(a)
{
case 1:
{
int num = 0;
int input = 0;
srand((unsigned)time(NULL));
num = rand()%100+1;
while(1)
{
printf("请输入1~100的数字:>");</span>
<span style="font-size:18px;"> scanf("%d",&input);
if(num==input)
{
printf("猜对啦\n");
break;
}
else if(num>input)
{
printf("猜小啦\n");
}
if(num<input)
{
printf("猜大啦\n");
}
}
}
case 0:
{
exit(0);
}
}
}
return 0;
}</span>
C语言 猜数字游戏
最新推荐文章于 2021-10-29 21:05:09 发布