从键盘任意输入一个年号,判断它是否是闰年。
符合下列条件之一为闰年:
(1)能被4整除,但不能被100整除
(2)能被400整除
#include <stdio.h>
#include <math.h>
int main()
{
int year,flag;
printf("Enter year:\n");
scanf("%d",&year);
if(year%4==0&&year%100!=0||year%400==0)
flag=1;
else
flag=0;
if(flag==1)
printf("%d is a leap year!\n",year);
else
printf("%d is not a leap year!\n",year);
return 0;
}