回复 13楼 吹水佬
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
void main()
{
int i,t,a[10]={0};
int m,counts=0;
srand(time(0));
for(i=0;i<10;i++)a[i]=0;
for(t=0;t<9876;)
{
i=rand()%10;
if(!a[i])
{
t=t*10+i;
a[i]++;
}
}
printf("game beginning\n");
printf("input five different numbers you guessed\n");
for(; ;)
{
scanf("%d",&m);
counts++;
if(m>t)
printf("Too high!\n");
else if(m<t)
printf("Too low!\n");
else
{
printf("right!
your score is %d\n",(100-counts+1));
printf("you guessed %d times\n",counts);
printf("right value is %d\n",t);
}
}
}