include<stdio.h>
include<math.h>
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<stdio.h>
include<stdlib.h>
include<time.h>
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;
}
网友评论