pro 5-4

include

include

int main()
{
int i,j;
j = rand() % 101;
while (1)
{
scanf("%d", &i);
if (i < j) printf("小了!\n");
else if (i > j) printf("大了!\n");
else printf("恭喜你!猜对了。\n");
}
return 0;
}
改进版:

include

include

include

int main()
{
int i,j;
srand(time(NULL));
j = rand() % 101;
while (1)
{
scanf("%d", &i);
if (i < j) printf("小了!\n");
else if (i > j) printf("大了!\n");
else printf("恭喜你!猜对了。\n");
}
return 0;
}

你可能感兴趣的:(pro 5-4)