C语言 求1000~2000的闰年 旧城等待, 2024-04-08 12:41 27阅读 0赞 ## 求1000~2000的闰年 ## #### 判断闰年的方法 #### **1.被4整除,不能被100整除地是闰年** **2.能被400整的是闰年** #include<stdio.h> int main() { int y = 0; int count = 0; //计算共有多少个闰年 for (y = 1000; y <= 2000; y++) { if (y % 400 == 0) { printf("%d ", y); count++; } if ((y % 4 == 0) && (y % 100 != 0)) { printf("%d ", y); count++; } } printf("%d", count); return 0; } 运行结果 ![运行结果][d6e6ac0053d24ea68cdaa79a8addb2a8.png_pic_center] **学的不是技术,更是梦想** [d6e6ac0053d24ea68cdaa79a8addb2a8.png_pic_center]: https://image.dandelioncloud.cn/pgy_files/images/2024/04/08/0d3eaca6bce2488cb0675e54734bc8ce.png
还没有评论,来说两句吧...