//思路:先写逻辑,这是或者的关系,满足其一条件即可,year%4==0&&year%100!=0 || year%400==0 int year; int s_leap = 0; for( year = 1000;year <= 2000; year++) //通常 区间左闭右开即 [...) { if(year%4==0 && year%100!=0) //if((year%4==0 && year%100!=0) || (year%400==0))就可以不用下边的else if语句 { s_leap++; printf( "leap_year:%d , This is %d leapyear\n",year,s_leap); } else if(year%400==0) { s_leap++; printf( "leap_year:%d , This is %d leapyear\n",year,s_leap); } }
return 0;