判断是否是闰年
计算闰年的方法:
如果某年能被4整除但不能被100整除,或者该年能被400整除则为闰年。
(year%4==0&&year%100!=0)||year%400==0
1 #include <stdio.h>
2
3 int main(void)
4 {
5 int year;
6 printf("please input the year:\n");
7 scanf("%d",&year);
8 if((year%4==0&&year%100!=0)||year%400==0)
9 printf("%d is a leap year\n",year);
10 else
11 printf("%d is not a leap year\n",year);
12
13 return 0;
14 }
运行结果如下: