#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(0)); int number = rand() % 100 + 1; int count = 0; int a = 0; do{ printf("请输入一个数 "); scanf("%d",&a); if(a < number){ printf("小了 "); } else if(a > number){ printf("大了 "); } count++; }while (a != number); printf("猜了%d次:", count); return 0; }