mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-11-27 14:36:19 +00:00
28 lines
463 B
C
28 lines
463 B
C
|
#include <stdio.h>
|
||
|
|
||
|
const int DAYS[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};
|
||
|
|
||
|
int main() {
|
||
|
int y, m, d;
|
||
|
|
||
|
scanf("%4d/%2d/%2d", &y, &m, &d);
|
||
|
|
||
|
int days = 0;
|
||
|
|
||
|
for (int i = 1; i < m; i++) {
|
||
|
days += DAYS[i];
|
||
|
|
||
|
if (i == 2) { // 2 月涉及到闰年
|
||
|
if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) {
|
||
|
days++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
days += d;
|
||
|
|
||
|
printf("%d\n", days);
|
||
|
|
||
|
return 0;
|
||
|
}
|