作业 3 应用分支与循环结构解决问题 判断是否闰年

/*判断是否为闰年*/
#include<stdio.h> int main(void) { int i,n,year;
printf("Enter n:"); /*提示输入n*/
scanf("%d",&n); /*输入n*/
for(i=1;i<=n;i++){ /*循环重复i次*/
printf("Enter year:"); /*提示输入年份*/
scanf("%d",&year); /*输入年份*/
if((year%4==0&&year%100!=0)||(year%400==0)){ /*如果年份除以4等于0并且年份除以100等于0,或者年份除以400等于0*/
printf("it is leap year"); /*输出“这是闰年”*/
} else{ printf("it is not leap year"); } } return 0; }
原文地址:https://www.cnblogs.com/huangsilinlana/p/3379624.html