#include <timeh>
#include <stdioh>
#include <stdlibh>
#define UI unsigned short int
void game()
{
UI answer;
UI input;
UI lower=1;
UI upper=100;
UI count=0;
srand(time(NULL));
do{answer=rand()%101;}
while(answer==0);
puts("Welcome to the number guessing game!");
do
{
puts("Please enter an integer from 1 to 100 (again):");
scanf("%lu",&input);
getchar();
count=count+1;
if(input==answer){puts("You succeeded!");printf("The number of time(s) you entered is %lu\n",count);}
else
{
puts("You failed!");
if(input<answer){if(input>lower){lower=input;}puts("The answer is greater than your input");}
else {if(input<upper){upper=input;}puts("The answer is less than your input");}
printf("The answer is from %lu to %lu\n",lower,upper);
}
}
while(input!=answer);
}
#undef UI
int main()
{
game();
system("Pause");
return 0;
}
以上就是关于c语言编程:猜数字游戏全部的内容,包括:c语言编程:猜数字游戏、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!