#include <stdio.h>int main() {int year, leap; //year年份 leap是否为闰年printf("Please enter year:");scanf_s("%d", &year);if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) //如果年份能被4整除且不能被100整除,或者直接能被400整除,则为闰年leap = 1; //闰年elseleap = 0; //非闰年if (leap)printf("%d is a leap year\n", year);elseprintf("%d is not a leap year\n", year);return 0;}
程序运行结果如下所示:
欢迎小伙伴讨论,如有错误请在评论区评论或发私聊消息,谢谢你。