思路:一种是从19600101 依次1枚举到 20590101,相对简单一些,另一种是直接对输入数据处理,并且需要注意很多边缘细节,例如02/02/02 特殊数据
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a,b,c;
string k;
int leap_year[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int fleap_year[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
void turn_num()
{
a=k[0]-48;
a=a*10+k[1]-48;
b=k[3]-48;
b=b*10+k[4]-48;
c=k[6]-48;
c=c*10+k[7]-48;
}
void shows(int u,int v,int w)
{
int year1=1900+u;
int year2=2000+u;
if(year1>=1960)
{
if(year1%4==0&&year1%100!=0||year1%400==0)
{
if(v>0&&v<=9&&w>0&&w<=9)
{
cout<<year1<<"-"<<"0"<<v<<"-"<<"0"<<w<<endl;
}
else if(v>=10&&v<=12&&w>=10&&w<=leap_year[v])
{
cout<<year1<<"-"<<v<<"-"<<w<<endl;
}
else if(v>0&&v<=9&&w>=10&&w<=leap_year[v])
{
cout<<year1<<"-"<<"0"<<v<<"-"<<w<<endl;
}
else if(v>=10&&v<=12&&w>0&&w<=9)
{
cout<<year1<<"-"<<v<<"-"<<"0"<<w<<endl;
}
}
else
{
if(v>0&&v<=9&&w>0&&w<=9)
{
cout<<year1<<"-"<<"0"<<v<<"-"<<"0"<<w<<endl;
}
else if(v>=10&&v<=12&&w>=10&&w<=fleap_year[v])
{
cout<<year1<<"-"<<v<<"-"<<w<<endl;
}
else if(v>0&&v<=9&&w>=10&&w<=fleap_year[v])
{
cout<<year1<<"-"<<"0"<<v<<"-"<<w<<endl;
}
else if(v>=10&&v<=12&&w>0&&w<=9)
{
cout<<year1<<"-"<<v<<"-"<<"0"<<w<<endl;
}
}
}
if(year2<=2059)
{
if(year2%4==0&&year2%100!=0||year2%400==0)
{
if(v>0&&v<=9&&w>0&&w<=9)
{
cout<<year2<<"-"<<"0"<<v<<"-"<<"0"<<w<<endl;
}
else if(v>=10&&v<=12&&w>=10&&w<=leap_year[v])
{
cout<<year2<<"-"<<v<<"-"<<w<<endl;
}
else if(v>0&&v<=9&&w>=10&&w<=leap_year[v])
{
cout<<year2<<"-"<<"0"<<v<<"-"<<w<<endl;
}
else if(v>=10&&v<=12&&w>0&&w<=9)
{
cout<<year2<<"-"<<v<<"-"<<"0"<<w<<endl;
}
}
else
{
if(v>0&&v<=9&&w>0&&w<=9)
{
cout<<year2<<"-"<<"0"<<v<<"-"<<"0"<<w<<endl;
}
else if(v>=10&&v<=12&&w>=10&&w<=fleap_year[v])
{
cout<<year2<<"-"<<v<<"-"<<w<<endl;
}
else if(v>0&&v<=9&&w>=10&&w<=fleap_year[v])
{
cout<<year2<<"-"<<"0"<<v<<"-"<<w<<endl;
}
else if(v>=10&&v<=12&&w>0&&w<=9)
{
cout<<year2<<"-"<<v<<"-"<<"0"<<w<<endl;
}
}
}
}
int main()
{
getline(cin,k);
turn_num();
if(a<b&&b<c)
{
shows(a,b,c);
shows(c,a,b);
shows(c,b,a);
}
else if(a<c&&c<b)
{
shows(a,b,c);
shows(c,a,b);
shows(c,b,a);
}
else if(b<c&&c<a)
{
shows(c,b,a);
shows(c,a,b);
shows(a,b,c);
}
else if(b<a&&a<c)
{
shows(a,b,c);
shows(c,b,a);
shows(c,a,b);
}
else if(c<a&&a<b)
{
shows(c,a,b);
shows(c,b,a);
shows(a,b,c);
}
else if(c<b&&b<a)
{
shows(c,b,a);
shows(c,a,b);
shows(a,b,c);
}
else if(a==b&&b==c)
{
shows(a,b,c);
}
else if(a==b&&c<a)
{
shows(c,a,b);
shows(a,b,c);
}
else if(a==b&&c>a)
{
shows(a,b,c);
shows(c,a,b);
}
}