#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
printf("--------------------------------------\n");
printf("| 数字炸弹 |\n");
printf("--------------------------------------\n");
int low=0,high=0;
printf("输入炸弹范围(?~?):");
scanf("%d~%d",&low,&high);
srand((unsigned int)time(NULL));
int a,b=0;
b=rand()%(high-low+1)+low;
while(1)
{
printf("猜一个炸弹数\n");
scanf("%d",&a);
if(a==b)
{
printf("猜中炸弹,boom");
break;
}
else
{
if(a<b)
low=a+1;
else
high=a-1;
printf("没有爆炸,炸弹范围:%d~%d\n",low,high);
}
}
return 0;
}