判断是不是闰年 2000–3000
package com.shipeiqi.yingyong;public class ClassP6 {static int LeapYear(int year){if((year%400 == 0) || (year%100!=0)&& (year%4==0)){return 1; //是闰年,则返回1}else{return 0; //不是闰年,则返回0}}public static void main(String[] args) {int year;int count = 0;System.out.println("2000年到3000年");for(year = 2000;year<=3000;year++){if(LeapYear(year) == 1){System.out.println(year+"");count++;if(count%16 == 0){System.out.print("n");}}}System.out.print("n");}
}
本文发布于:2024-01-28 09:11:49,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17064043156352.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |