Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package vn.com.hoangminh.Physics;
- import java.lang.reflect.Array;
- import java.util.Scanner;
- public class DisplayLeapYear {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Nhập năm đầu : ");
- int start = input.nextInt();
- System.out.print("Nhập năm cuối : ");
- int end = input.nextInt();
- DisplayLeapYear display = new DisplayLeapYear();
- display.compute(start,end);
- }
- public void compute(int start, int end) {
- int[] nhap = new int[end];
- int[] output = new int[end];
- int j = 0;
- for(int i = start; i <= end; i++) {
- if( i % 400 == 0 ) {
- output[j] = i;
- j++;
- }
- else if( i % 100 != 0 && i % 4 == 0 ) {
- output[j] = i;
- j++;
- }
- }
- System.out.println("Các năm leap là : ");
- for(int a = 0; a <= j; a++) {
- System.out.print( output[a] + " ");
- if( a % 8 == 7 ) System.out.print("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment