好玩的猜数小游戏
#include<time.h>
int main()
{
srand(time(NULL));
//范围为1-100
//1. 94+1-8=87
int num = rand() % 100 + 1;
while(1)
{
int guess;
printf("请输入猜的数字:");
scanf_s("%d", &guess);
if (guess == num)
{
printf("猜对了\n");
break;
}
else if(guess >= num)
{
printf("猜大了\n");
}
else
{
printf("猜小了\n");
}
}
return 0;
}