1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| import java.util.Scanner;
public class runnian { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("请输入年份"); int nianfen = s.nextInt(); if (nianfen % 400 == 0) { System.out.println(nianfen + "年是闰年"); } else if (nianfen % 100 == 0) { System.out.println(nianfen + "年不是闰年"); } else if (nianfen % 4 == 0) { System.out.println(nianfen + "年是闰年"); } else { System.out.println(nianfen + "年不是闰年"); } } }
|