输出 1000 - 2000 之间所有的闰年
package com.Test5;
public class Test5 { //定义Test5类
//主函数
public static void main(String[] args){
int year = 1000; //year始于1000
while(year <= 2000) { //当year小于2000
if (year % 100 == 0) { //若year是世纪闰年
if (year % 400 == 0) {
System.out.println(year + "是闰年.");
} else {
}
} else { //若year不是世纪闰年
if (year % 4 == 0) {
System.out.println(year + "是闰年.");
} else {
}
}
year++; //year向2000靠近
}
}
}