2025-02-20 23:18:47 +08:00

32 lines
509 B
C

#include <stdio.h>
int main(void){
int year, month, day, days=0;
scanf("%d-%d-%d", &year, &month, &day);
days+=day;
//1 3 5 7 8 10 12
//从前一个月开始依次
switch(month-1){
case 11:days+=30;
case 10:days+=31;
case 9:days+=30;
case 8:days+=31;
case 7:days+=31;
case 6:days+=30;
case 5:days+=31;
case 4:days+=30;
case 3:days+=31;
case 2:days+=28;
case 1:days+=31;
}
if(month>3 && (year%4==0&&year%100!=0 || year%400==0)){
days++;
}
printf("%d\n", days);
return 0;
}