一年的天数 Exercise06_16

 1 /**
 2  * @author 冰樱梦
 3  * 时间:2018年下半年
 4  * 题目:一年的天数
 5  *
 6  */
 7 public class Exercise06_16 {
 8     public static void main(String[] args){
 9         for(int i=2000;i<=2020;i++){
10             System.out.print(numberOfDaysInAYear(i)+" ");
11         }
12     }
13     //返回天数
14     public static int numberOfDaysInAYear(int i){
15         int years;
16         if((i%4==0 && i%100!=0)||(i%400==0)) years=366;
17         else years=365;
18         return years;
19     }
20 }

 

posted @ 2018-12-25 14:42  CHERRYL  阅读(205)  评论(0编辑  收藏  举报