从键盘中输入两个年份,输出这两个年份之间的所有的闰年年份。

代码:

import java.util.Scanner;

public class Main {
    public static void main(String args[]){       
           Scanner reader=new Scanner(System.in);
           int m=reader.nextInt();
           int n=reader.nextInt();
           int k=0;
           for(int i=m;i<=n;i++)
           {
               if((i%4==0&&i%100!=0)||(i%400==0))
               {
                   System.out.print(i+" ");
                   k++;
                   if(k%4==0)
                       System.out.println();
               }
           }
        }
}
0

Leave a Reply

Your email address will not be published.