[求助]
各位朋友好!!
呵呵
猜数游戏,计算机"想"一个数 请人猜,如果人猜对了,则结束游戏,否则计算机给出提示,告诉人所猜的数是太大还是太小,直到人猜对为止。计算机记录人猜的次数,以此可以反映出猜数者"猜"的水平!
有哪位帅哥,靓妹可以告诉我??
谢了 在线等解答!
#include <stdio.h>
#include <stdlib.h>
main()
{int magic;
int guess;
int count;
magic=rand();
guess=magic-1;
counter=0;
while(magic!=guess)
{printf("guess the magic number:");
scanf(%d,"&guess);
counter++;
if(guess>magic)
print("you are wrong. the number is too hight\n");
else if(guess<magic)
printf("you are wrong.the number is too low\n");
}
printf("you are right\n");
printf("the guess counter is %d\n",counter);
[此贴子已经被作者于2005-12-2 22:35:29编辑过]