判断一个年份是否为闰年

#include <stdio.h>
int main() {
	printf("please input a number,we can judge it\n");
	int year;
	int re = scanf("%d", &year);
	if (year % 4 == 0 && year % 100 != 0 || year % 100 == 0 && year % 400 == 0) {
		printf("%d is a leap year", year);
	}
	else {
		printf("%d is not a leap year", year);
	}
	return 0;
}


ctrl+F5 输入需要判断的年份 此处使用2001

alt

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务