猜数字游戏
//设计猜数字小游戏,只能猜七次。
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
srand(time(0));
int key=rand()%100;
int n=7,x;
int start=1,end=100;
while(n--)
{
scanf("%d",&x);
x=(start+end)/2;
printf("Current range is [%d,%d]\n",start,end);
if(x==key)
{
printf("congratulation!\n");
break;
}
else if(x<key)
{
start=x+1;
printf("too samll~\n");
}
else { end=x-1; printf("too big~");}
}
return 0;
}