#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void menu()
{
printf("1.play\n");
printf("0.exit\n");
printf("请选择\n");
}
void game()
{
int guess = 0;
int ret = rand()%100+1;
//printf("%d\n\n", ret);
while (1)
{
printf("老实猜数字\n");
scanf_s("%d",&guess);
if (guess < ret)
{
printf("小了\n");
}
else if (guess > ret)
{
printf("大了");
}
else
{
printf("猜对了\n");
break;
}
}
}
int main()
{
int input = 0;
srand((unsigned int)time(NULL));
do
{
menu();
scanf_s("%d", &input);
switch (input)
{
case 1:
printf("***猜数字***\n");
game();
break;
case 0:
printf("***退出游戏***\n");
break;
default:
printf("选择错误,重新选择!\n");
break;
}
} while (input);
return 0;
}
猜数游戏——可恶的喵桑
最新推荐文章于 2024-09-11 14:54:26 发布