题解 | #计算日期到天数转换#
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
String[] arr = str.split(" ");
int year = Integer.valueOf(arr[0]);
int month = Integer.valueOf(arr[1]);
int day = Integer.valueOf(arr[2]);
int num = 0;
for (int i = 1; i < month; i++) {
num = num + 31;
if (i == 4 || i == 6 || i == 9 || i == 11) {
num = num - 1;
}
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
if (i == 2) {
num = num - 2;
}
} else {
if (i == 2) {
num = num - 3;
}
}
}
System.out.print(num + day);
}
}

