文章
79
粉丝
221
获赞
46
访问
198.3k
#include <iostream>
#include <string>
using namespace std;
//返回日期1是否早于日期2
bool Comp(string dat1, string dat2) {
for (int i = 0; i < dat1.size(); i++)
if (dat1[i] != dat2[i])
return dat1[i] <= dat2[i];
}
bool IsR(int year) {
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
int Past(int y, int m, int d) {
int res = 0;
for (int i = 1; i < m; i++) {
if (i == 2)
res += IsR(i) ? 29 : 28;
else
res += (i < 8 && i % 2 != 0) || (i >= 8 && i % 2 == 0) ? 31 : 30;
}
return res+d;
}
int main() {
string dat1, dat2;
while (cin >> dat1 >> dat2) {
if (!Comp(dat1, dat2))
swap(dat1, dat2);
int y1 = 0, y2 = 0, m1 = 0, m2 = 0, d1 = 0, d2 = 0;
for (int i = 0; i < 4; i++)
y1 = y1 * 10 + dat1[i] - '0', y2 = y2 * 10 + dat2[i] - '0';
for (int i = 4; i < 6; i++)
m1 = m1 * 10 + dat1[i] - '0', m2 = m2 * 10 + dat2[i] - '0';
for (int i = 6; i < 8; i++)...
登录后发布评论
暂无评论,来抢沙发