Files
python/TangDou/LianXiTi50/14_TangDou.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

26 lines
662 B
C++

#include <iostream>
using namespace std;
int month_1[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int month_2[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool LeapYear(int year) {
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) return true;
return false;
}
int main() {
int y, m, d, days = 0;
cin >> y >> m >> d;
if (LeapYear(y)) {
for (int i = 1; i <= m - 1; ++i)
days += month_2[i];
days += d;
} else {
for (int i = 1; i <= m - 1; ++i)
days += month_1[i];
days += d;
}
printf("%d", days);
return 0;
}