C++ 代码
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include<set>
using namespace std;
int main()
{
int a, b, c;
scanf("%d/%d/%d",&a,&b,&c);
vector<string> ans;
int month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
int st[3][3] = { a,b,c ,
c,a,b,
c,b,a, };
for (int i = 0;i < 3;i++) {
int y = st[i][0];
int m = st[i][1];
int d = st[i][2];
if (y >= 60) {
y += 1900;
}
else {
y += 2000;
}
if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) {
month[2] = 29;
}
if (m <= 12 && d <= month[m]&&m>0&&d>0) {
string s;
s += to_string(y);
s += "-";
if (m < 10) {
s += "0";
s += to_string(m);
}
else {
s += to_string(m);
}
s += "-";
if (d < 10) {
s += "0";
s += to_string(d);
}
else {
s += to_string(d);
}
ans.push_back(s);
}
month[2] = 28;
}
sort(ans.begin(), ans.end());
set<string> s (ans.begin(), ans.end());
ans.assign(s.begin(), s.end());
for (string a:ans) {
cout << a << endl;
}
}