编辑代码

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main () {
srand(time(0));
int number=rand()%100+1;
int time=0;
int a;

printf("I have think of a number from 1 to 100.\n");
do{
    printf("Please guess what it is.\n");
    scanf("%d",&a);
    time++;
    if(a<number)
    printf("Larger\n");
    else if(a>number)
    printf("Smaller\n");
    else
    printf("You use %d times to guess the answer, congratulations!",time);
}
while(a!=number);
return 0;
}