pro 5-4

2017-10-09  本文已影响2人  Zdhj

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;
}

上一篇下一篇

猜你喜欢

热点阅读