#include"stdio.h"
#include"time.h"
#include"stdlib.h"
void main()
{
clock_t start,over;
double time;
int k=42,a=0;
char ch='a';
start=clock();
scanf("%d",&a);
leap:while(a!=k)
{
if(a>k)
printf("too high");
else
printf("too low");
scanf("%d",&a);
}
printf("答案是%d",k);
k=rand()%100;
scanf("%c",&ch);
if(ch!='n')
goto leap;
over=clock();
time=double(over-start)/CLOCKS_PER_SEC;
printf("总时间=%.0f秒",time);
}
按出答案后又会直接进入判断。。。。
按完答案后再按n会进入死循环