/*描述
输入一个年份与月份,输出该年该月的天数。
输入
2个整数表示年份与月份。
输出
天数。
样例输入
2012 2
2011 2
1999 4
1998 5
样例输出
29
28
30
31*/
import java.util.*;
public class Main5 {
public static int year, month;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
year = sc.nextInt();
month = sc.nextInt();
if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
if (month == 2) {
System.out.println(29);
} else {
if (month < 8 && month % 2 != 0 || month >= 8
&& month % 2 == 0) {
System.out.println(31);
} else {
System.out.println(30);
}
}
} else {
if (month == 2) {
System.out.println(28);
} else {
if (month < 8 && month % 2 != 0 || month >= 8
&& month % 2 == 0) {
System.out.println(31);
} else {
System.out.println(30);
}
}
}
}
}
}
输出某个月的天数
最新推荐文章于 2023-12-02 09:57:20 发布