判断规则:1.能被4整除,不能被100整除是闰年,2.能被400整除是闰年
#include <stdio.h>int is_leap_year(int n){if((n % 400 == 0)||((n % 4 == 0)&&(n % 100 != 0)))return 1;elsereturn 0;
}
int main()
{int i = 0;int count = 0;for(i = 1000;i <= 2000;i = i + 4)if(is_leap_year(i)){printf("%d是闰年\n",i);count++;}printf("%d个闰年\n",count);return 0;
}
结果如图: