代码语言:javascript复制
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(void)
{
int num = 0;
srand((unsigned)time(NULL));
int i = rand();
while (scanf("%d", &num) != EOF)
{
if (num == i)
{
printf("恭喜你,猜对了。n");
break;
}
else
{
printf("不对哦,继续猜。n");
}
}
printf("游戏结束。");
return 0;
}