輸出某年某月有幾天

import java.util.Scanner;


public class Test01 {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
int month = sc.nextInt();
int days = 0;
switch (month) {
case 2:
if((year%4==0&&year%100!=0)||year%400==0){
days = 29;
}else{
days = 28;
}
break;
case 4:
case 6:
case 9:
case 11:
days = 30;
break;


default:
days = 31;
break;
}
System.out.println(days);


}


}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章