请问大佬们,写好一个小游戏以后,该如何优化?
#include<stdio.h>#include<stdlib.h>
#include<time.h>
#define _CRT_SECURE_NO_WARNINGS
int Menu()
{
printf("***************************\n");
printf("*********1.开始游戏********\n");
printf("*********0.结束游戏********\n");
printf("***************************\n");
int giao = 0;
system("color 0A");
printf("请输入你的选项:");
scanf("%d", &giao);
return giao;
}
void Game()
{
int one_number = rand () % 1000 + 1;
while (1)
{
printf("请输入一个数[1-1000]:");
int input_number = 0;
scanf("%d", &input_number);
if (input_number > one_number)
{
printf("数字大了!\n");
}
else if (input_number < one_number)
{
printf("数字小了!\n");
}
else
{
printf("恭喜你答对了!\n");
break;
}
}
}
int main()
{
srand((unsigned int)time(0));
while (1)
{
int giao = Menu();
if (giao == 1) /*开始游戏*/
{
Game();
}
else if (giao == 0)
{
printf("Good bye!\n");
}
else
{
printf("请正确输入!!!\n"); /*int giao=Menu*/
}
}
system("pause");
return 0;
}