标签:计算 ret turn please lse while big scanf print
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
int magic; //计算机随机生成的数
int guess; //人猜的数
int counter;//记录猜的次数
magic = rand() % 100 + 1; //1到100的随机数
counter = 0;
do{
printf("Please guess a magic number:");
scanf("%d",&guess);
counter++;
if (guess > magic)
{
printf("Wrong! Too big!\n");
}
else if (guess < magic)
{
printf("Wrong! Too small!\n");
}
else
printf("Right!\n");
}while (guess !=magic);
printf("The number is:%d\n",magic);
printf("counter = %d \n",counter);
return 0;
}
标签:计算 ret turn please lse while big scanf print
原文地址:https://www.cnblogs.com/zhkk/p/9683700.html