思路:
每月有多少天是固定的,放到数组中,2月单独判断一下。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int y = sc.nextInt();
int d = sc.nextInt();
int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
if((y%4==0 && y%100!=0) || y%400 == 0) {
days[1] = 29;
}
int m = 0;
while(d > days[m]) {
d -= days[m];
m++;
}
System.out.println(m+1);
System.out.println(d);
}
}