下面程序要求用户从键盘输入一个年号,然后由程序判定其是否是闰年。 年号分别为:1995,2000,1800,2010,2018 #include
int main() { int year,r4,r100,r400; printf("Input a year number:\n"); scanf("%d",&year); r4 = year % 4; r100 = year % 100; r400 = year % 400; if( (r4 == 0 && r100 != 0) || r400 == 0) printf("%d is a leap year\n",year); else printf("%d is not a leap year\n",year); }