C语言简单的猜数字游戏

2023-05-12 21:07:43 浏览数 (1)

代码语言: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;
}

0 人点赞