2 条题解
-
0
先判断闰年,如果是就把2月天数变为29,最后累加求和即可
#include <bits/stdc++.h> using namespace std; int yue[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int ans; int a, b, c; char c1, c2; int main() { cin >> a >> c1 >> b >> c2 >> c; if ((a % 4 == 0 && a % 100 != 0) || (a % 400 == 0)) yue[2] = 29; for (int i = 1; i < b; i++) ans += yue[i]; cout << ans + c; return 0; }
-
0
可耻的打表(月份而已,虚惊亿场)诶,这是AC呀!
#include <bits/stdc++.h> using namespace std; int a[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; int main() { int y,m,d; char gang; cin >> y >> gang >> m >> gang >> d; int day = d; if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) a[2] = 29; for (int i = 1;i < m;i++) { day += a[i]; } cout << day; }
- 1
信息
- ID
- 1143
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- 递交数
- 14
- 已通过
- 12
- 上传者