#include<stdio.h>
void menu()
{
printf("**************************\n");
printf("******1:play 2:end *******\n");
printf("**************************\n");
}
void game()
{
int red, guess;
red = rand() % 100 + 1;
while (1)
{
printf("请猜数字>:");
scanf("%d", &guess);
if (guess > red)
printf("猜大了>:\n");
else if (guess < red)
printf("猜小了>:\n");
else
printf("恭喜你!猜对了>:\n");
}
}
int main()
{
int input = 0;
srand((unsigned int) time(NULL));
do {
menu();
printf("请输入>:");
scanf("%d", &input);
switch (input)
{
case 1:
game();
break;
case 2:
printf("退出游戏\n");
break;
default:
printf("选择错误");
break;
}
} while (input);
return 0;
}
1279

被折叠的 条评论
为什么被折叠?



