版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tobe_numberone/article/details/88622716
import java.util.Scanner;
class Main {
public static boolean ifleapYear(int year) {
if ((year%4==0 && year%100!=0) ||year%400 == 0){
return true;
}
return false;
}
public static int sumab(int a,int b) {
a-=1;b-=1;
int[] month = {31,28,31,30,31,30,31,31,30,31,30,31};
int sum = 0;
for(int i= a;i<=b;i++) {
sum+=month[i];
}
return sum;
}
public static int countDays(int y,int m,int d) {
boolean leapYear = ifleapYear(y);
boolean overTwo = (m-1)>=2;
if (leapYear && overTwo) {
return sumab(1,m-1)+d+1;
}
return sumab(1,m-1)+d;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner read = new Scanner(System.in);
while(read.hasNextLine()) {
String str = read.nextLine();
String[] data = str.split("/");
int y = Integer.parseInt(data[0]);
int m = Integer.parseInt(data[1]);
int d = Integer.parseInt(data[2]);
System.out.println(countDays(y,m,d));
}
read.close();
}
}