Leap Year

作者: 綿綿_ | 来源:发表于2019-04-01 15:24 被阅读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");
        }
    
    } 
    

    相关文章

      网友评论

          本文标题:Leap Year

          本文链接:https://www.haomeiwen.com/subject/fysvbqtx.html