标签:return ret pre exit unsigned while void lib main
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void menu()
{
printf("***************************\n");
printf("******* 1.play *******\n");
printf("******* 0.exit *******\n");
printf("***************************\n");
}
void game()
{
int number = rand() % 100 + 1;
int input = 0;
while (1)
{
printf("请输入猜的数字\n");
scanf("%d", &input);
if (input > number)
{
printf("提示!猜大了\n");
}
else if (input < number)
{
printf("提示!猜小了\n");
}
else
{
printf("恭喜你,猜对了");
break;
}
}
}
int main()
{
system("color 7F");//78
int input = 0;
srand((unsigned)time(NULL));
do
{
menu();
printf("请选择->");
scanf("%d", &input);
switch(input)
{
case 1:game();
case 0:break;
dafult:printf("选择错误,请重新选择\n");
}
} while (input);
return 0;
}
标签:return ret pre exit unsigned while void lib main
原文地址:https://blog.51cto.com/14737345/2477294