写一个函数判断year是不是闰年

#include
int  judge_leap(int year)
{
	if (((year % 4 == 0)&(year % 100 != 0)) || (year % 400 == 0))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main()
{
	int y = 0;
	printf("请输入要判断的年份:");
	scanf("%d", &y);
	int ret = judge_leap(y);
	while (ret)
	{
		printf("this year is a leap year\n");
		break;
	}
	system("pause");
	return 0;
}

你可能感兴趣的:(C语言)