源程序:
public class Test{
public static void main(String[] args){
int year = (int)(Math.random() * 3000) ;
if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0){
System.out.println(year + "是闰年") ;
}
else
System.out.println(year + "不是闰年") ;
}
}
运行结果: