#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
void menu()
{
printf("***************************\n");
printf("*****1 play******0 exit****\n");
printf("***************************\n");
}
void game()
{
int random = rand()%100+1;//1---100之间的数
int input;
while(1)
{
scanf("%d",&input);
if(input<random)
{
printf("猜小了\n");
}
else if(input>random)
{
printf("猜大了\n");
}
else
{
printf("恭喜你,猜对了\n");
break;
}
}
}
int main()
{
int input;
do
{
menu();
printf("please enter:\n");
scanf("%d",&input);
srand((unsigned)time(NULL));
switch(input)
{
case 1:
game();
break;
case 0:
break;
default:
printf("enter is error,please enter again\n");
break;
}
}while(1);
system("pause");
return 0;
}
猜数字的游戏
最新推荐文章于 2024-07-31 11:27:55 发布