#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void menu()
{
printf("1=开始游戏\n");
printf("0=不进行游戏\n");
printf("请选择:");
}
void game()
{int num=rand()%100+1;
int input=0;
printf("猜猜看啊");
while(1)
{
static int right = 100;
static int left = 0;
scanf("%d",&input) ;
if (input > num)
{
right = input-1;
printf("炸弹在%d到%d中\n",left,right);
}
else if (input < num)
{
left = input + 1;
printf("炸弹在%d到中%d\n", left, right);
}
else{
printf("bow\n") ;
break;
}
}
}
int main()
{srand((unsigned)time(NULL));
int a=0;
do
{
menu();
printf("请选择:");
scanf("%d",&a);
switch (a)
{
case 1:game();
break;
case 0:
printf("see you!\n");
break;
default:
printf("错误");
break;
}
}while(a);
return 0;
}
标签:right,int,C语言,break,小游戏,printf,input,100,left From: https://blog.csdn.net/SHAO060706/article/details/142653980