#include<stdio.h>
#include<time.h>
#include<stdlib.h>
void menu()
{
printf("********************************\n");
printf("****** 1.开始 2.退出 ******\n");
printf("********************************\n");
}
void game()
{
int guess = 0;
int ret = 0;
ret = rand() % 100 + 1;
while (1)
{
printf("猜个数字:");
scanf_s("%d", &guess);
if (guess > ret)
printf("猜大了\n");
else if (guess < ret)
printf("猜小了\n");
else
{
printf("猜对啦\n");
break;
}
}
}
int main()
{
int input = 0;
srand((unsigned int)time(NULL));
do
{
menu();
printf("请选择:");
scanf_s("%d", &input);
switch (input)
{
case 1:
game();
break;
case 2:
printf("退出\n");
goto A;
break;
default:
printf("输入错误\n");
break;
}
} while (input);
A:return 0;
}