http://topic.csdn.net/t/20061130/17/5197792.html5.闰年:
列出从1000年到3000年中所有闰年的年份?public class Demo1 {public boolean fun(int i)
{
//闰年的年份?
//...?
} public static void main(String[] args) {
//?从1000年到3000年中所有闰年的年份
//
}
}
列出从1000年到3000年中所有闰年的年份?public class Demo1 {public boolean fun(int i)
{
//闰年的年份?
//...?
} public static void main(String[] args) {
//?从1000年到3000年中所有闰年的年份
//
}
}
*
*//**
* @author Administrator
*
*/
public class Demo1 { public boolean fun(int i)
{
//闰年的年份?
if((i%4==0)&&(i%100!=0)||(i%400==0))
return true;//是闰年
else
return false;//不是闰年
//...?
} public static void main(String[] args)
{ //?从1000年到3000年中所有闰年的年份
//
Demo1 demo=new Demo1();
for(int i=1000;i<=3000;i++)
if(demo.fun(i)==true)
System.out.println(i); }
}
public boolean fun(int i){
return i%400==0||i%4==0&&i%100!=0;
}