# include<stdio.h>
# include<windows.h>
void main()
{
int year, leap;
printf("please enter a year:");
scanf("%d", &year);
if (year % 4 != 0) leap = 0; /*不能被4整除不是闰年*/
else if (year % 100 != 0) leap = 1; /*不能被100整除是闰年*/
else if (year % 400 != 0) leap = 0; /*不能被400整除不是闰年*/
else leap = 1; /*其余都是闰年*/
if (leap)
printf("%d is ", year);
else
printf("%d is not ", year);
printf("a leap year\n");
system("pause");
}
编程求闰年
最新推荐文章于 2023-11-13 16:33:34 发布