#include
/*判断闰年 1:是;0:否*/
/*闰年特点:年份是4的倍数但不是100的倍数、年份是400的倍数*/
int isLeap (int year) {
return (year%4==0 && year%100!=0) || (year%400==0);
}
int main (void) {
int year;
printf ("请输入年份:");
scanf ("%d",&year);
putchar ('\n');
if (isLeap (year))
printf ("%d年是闰年!\n",year);
else
printf ("%d年是平年!\n",year);
putchar ('\n');
getch ();
return 0;
}
运行结果
#include
int main()
{int y;
scanf("%d",&y);
if(y%4==0&&y%100!!=0||y%400==0)
printf("闰年\n");
else
printf("平年\n");
return 0;
}