C语言实现简单的猜数字游戏

1.进入游戏

2.退出游戏

void Print()
{
printf("******************************\n");
printf("*                            *\n");
printf("*    欢迎来到猜数字小游戏    *\n");
printf("*   1.play       2.exit      *\n");
printf("*                            *\n");
printf("******************************\n");

}

void Play()
{
int num = rand()% 100 + 1;//产生100以内的随机数
int guess;
printf("请输入你猜的数字（1-100）：\n");
while (scanf("%d", &guess))
{
if (guess == num)
{
printf("恭喜你！猜对啦！！\n");
break;
}
else if (guess > num)
{
printf("猜大了！！\n");
}
else
{
printf("猜小了！！\n");
}
}
}

int main()
{
srand((unsigned)time(NULL));
int choice;
Print();
while (scanf("%d", &choice))
{
if (choice == 1)
{
Play();
}
else if (choice == 2)
{
printf("        bye~  下次见！   \n");
break;
}
else
{
printf("请重新输入：\n");
}
}

return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void Print()
{
printf("******************************\n");
printf("*                            *\n");
printf("*    欢迎来到猜数字小游戏    *\n");
printf("*   1.play       2.exit      *\n");
printf("*                            *\n");
printf("******************************\n");

}
void Play()
{
int num = rand()% 100 + 1;//产生100以内的随机数
int guess;
printf("请输入你猜的数字（1-100）：\n");
while (scanf("%d", &guess))
{
if (guess == num)
{
printf("恭喜你！猜对啦！！\n");
break;
}
else if (guess > num)
{
printf("猜大了！！\n");
}
else
{
printf("猜小了！！\n");
}
}
}
int main()
{
srand((unsigned)time(NULL));
int choice;
Print();
while (scanf("%d", &choice))
{
if (choice == 1)
{
Play();
}
else if (choice == 2)
{
printf("        bye~  下次见！   \n");
break;
}
else
{
printf("请重新输入：\n");
}
}

return 0;
}

07-17

12-07
10-26
06-25
01-15
03-24 1万+
09-29 7944
09-14 2375
03-03
04-09
05-18 35
10-17 781
01-26 1万+
07-27 1万+
06-22 9652
04-02 2万+