c语言--猜数游戏(反应用户猜数水平)

#include

#include

int main()

{

int magic;

int guess;

int counter = 0;

magic = rand() % 100 + 1;

do{

printf("please guess a magic numbre:");

scanf("%d",&guess);

counter++;

if(guess>magic)

printf("Wrong! Too big!\n");

else if(guess

printf("Wrong! Too small!\n");

else

printf("Right!\n");

}while(guess ! = magic);

printf("counter = %d\n",counter);

return 0;

}

你可能感兴趣的:(c语言)