#include <string>
void h(int q[],int w[],int e[])
{
if (q[0] >= 60)
{
q[1] = q[0] + 1900;
}
else
{
q[1] = q[0] + 2000;
}
if (w[0] > 12)
{
return;
}
else
{
w[1] = w[0];
}
if (e[0] > 31)
{
return;
}
if (e[0] == 31 && (w[1] == 2 || w[1] == 4 || w[1] == 6 || w[1] == 9 || w[1] == 11))
{
return;
}
if (e[0] == 29 && (w[1] != 2 || q[0] % 4 != 0))
{
return;
}
else if (e[0] == 29 && (w[1] != 2 || q[0] % 4 == 0))
{
return;
}
else
{
e[1] = e[0];
}
cout << q[1] << "-";
if (w[1] > 9)
{
cout << w[1] << "-";
}
else
{
cout << "0" << w[1] << "-";
}
if (e[1] > 9)
{
cout << e[1] << endl;
}
else
{
cout << "0" << e[1] << endl;
}
}
int main()
{
string a = "02/03/04";
int q[2] = { stoi(a.substr(0, 2)) };
int w[2] ={ stoi(a.substr(3, 5))};
int e[2] = { stoi(a.substr(6, 8)) };
h(q, w, e);
h(e, q, w);
h(e, w, q);
}
ifelse判断,就硬写。