首页 > 其他分享 >例2.3 判定2000-2500年终的每一年是否为闰年。闰年条件:(1)能被4整除但不能被100整除 (2)能被400整除

例2.3 判定2000-2500年终的每一年是否为闰年。闰年条件:(1)能被4整除但不能被100整除 (2)能被400整除

时间:2022-09-29 23:32:05浏览次数:48  
标签:run 闰年 int 400 year printf 整除

*#include<stdio.h>

int main() {

for (int year = 2000; year <= 2500; year++) {

 if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {

  printf("%d is run year\n", year);

 }

 else {

  printf("%d isn't run year\n", year);

 }

}  

return 0;

}

标签:run,闰年,int,400,year,printf,整除
From: https://blog.51cto.com/u_15804165/5724453

相关文章