关于猜数的题目!!存在一些问题呢!!
#include<stdio.h>#include<stdlib.h>
#include<time.h>
int main(void)
{
int a,n,d,flag=1,sign=1,max,min,t,time;
int *k;
printf("Welcome you use this game:");
srand((int)time(&k)); // 产生随机时间
srand (k);
while(flag)
{
a=rand()%1000+1;
max=1000;
min=1;
t=0;
printf("please input you guess n: %d-%d",min,max);
scanf("%d",&n);
t++;
while(sign)
{ if(n>a) { if(n<max) max=n; printf("The number is hight :please input again:%d-%d",min,max);
scanf("%d",&n);sign=1;t++;}
else if(n<a) {if(n>min) min=n; printf("The number is low :please input again :%d-%d",min,max);
scanf("%d",&n);t++; sign=1;}
else if(n==a) {printf("You are good\n t=%d:",t);sign=0;}
}
printf("Are you continue 1 or 0:\n");
scanf("%d",&d) ;
if(d==1)
{flag=1;sign=1;}
else flag=0;
}
printf("Welcome you play again:\n");
}
一个关于猜1到1000之间的数呢 !!但为什么我那个关于时间的随机有问题呢!!