#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int search(int k,int a[],int len)
{
int ret=-1;
int i;
}
srand(time(0));
int num=rand()%100+1;
int x;
printf("Welcome to the game.\nThe system seclected a number from 1 to 100.\n");
time_t t;
char *pc;
time(&t);
pc=ctime(&t);
printf("Current time is:%s\n\n",pc);
printf("Please guess the number from 1 to 100.\n");
int count=0;
do
{
scanf("%d",&x);
count++;
if(x>num)
{
printf("The number is big!\n");
}
else if(x<num)
{
printf("The number is small!\n");
}
}while(x!=num);
printf("Congratulation!!! You have successed by %d chances.\n\n\n",count);
return main();
}
开发环境,dec-c++