闰年判断

第一次提交的时候没有得到全分,在年数为400倍数的时候判断错误,此时应输出yes,我将if放错了位置

 1 import java.util.*;
 2 
 3 public class Main {
 4     public static void main(String args[]) {
 5         Scanner scanner= new Scanner(System.in);
 6         int y = scanner.nextInt();
 7         if (y%4 == 0 && y%100 != 0) {
 8             System.out.println("yes");
 9         } else {
10             if (y%400 == 0) {
11                 System.out.println("yes");
12             }else {
13                 System.out.println("no");
14             }
15         }
16     
17     }
18 }

 

posted @ 2023-03-15 03:16  帆のBlog  阅读(16)  评论(0)    收藏  举报