一个猜数字小游戏
#include<iostream.h>
#include<stdlib.h>
#include<dos.h>
int main()
{
int max=100,min=1,i,k,n;
struct time t;
gettime(&t);
srand(t.ti_hund);
for(k=1;k<101;k++)
{
n=0;
for(i=0;i<1000;i++)
{
while(min<max)
{
int temp=rand()%(max-min+1)+min;
if(temp>k) max=temp-1;
if(temp<k) min=temp+1;
if(temp==k) {n++;break;}
n++;
}
cout<<n/1000.0;
}
}
getchar();
return 0;
}
我的执行结果是死循环,请问哪句有问题?