Leap Year

2019-04-01  本文已影响0人  綿綿_
public class LeapYear {
    static int leapYear(int year)
    {
        if ((year%400==0) || (year%100!=0) && (year%4==0))
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
    public static void main (String[] args)
    {
        int year;
        int count=0;
        
        System.out.println("the leap year between 2000 to 3000 is below:");
        for(year=2000;year<=3000;year++)
        {
            if(leapYear(year)==1)
            {
                System.out.print(year+" ");
                count++;
                if(count%15==0)
                    System.out.print("\n");
            }
        }
        System.out.print("\n");
    }

} 
上一篇下一篇

猜你喜欢

热点阅读