class Test{
public static void main(String[] args){
double x=Math.random()*10000;
x=Math.ceil(x);
int random=new Double(x).intValue();
System.out.println(random);
if((random%4==0&&random%100!=0)||random%400==0){
System.out.println("那一年为闰年");
}
else{
System.out.println("那一年为平年");
}
}
}
我这是随机产生0-9999的年号,怎么样才能随机产生1000-9999的年号??谢谢
public static void main(String[] args){
double x=Math.random()*10000;
x=Math.ceil(x);
int random=new Double(x).intValue();
System.out.println(random);
if((random%4==0&&random%100!=0)||random%400==0){
System.out.println("那一年为闰年");
}
else{
System.out.println("那一年为平年");
}
}
}
我这是随机产生0-9999的年号,怎么样才能随机产生1000-9999的年号??谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货