{
int Number = 2;
srand((unsigned)time(NULL));
int magic;
int guess;
int counter;
magic=rand()%100+1;
counter=0;
do{
printf("please guesss a magic number(0到100之间):");
scanf("%d",&guess);
counter++;
if (guess>magic)
printf("wrong!too high!你怎么这么苯,猪脑啊\n");
else if(guess
if(counter>=Number)break;
}
while(guess!=magic);
if (counter>=Number) printf("失败!超过最多猜题次数了!\n");
else
{
printf("right!终于猜对了\n");
printf("\t* *\n");
printf("\t *\n");
printf("counter=%d\n",counter);
}
}
用for循环啊!