#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
int main()
{
vector<int>year;
vector<int> month;
vector<int>day;
char a, b;
int c, d, e;
while (cin >> c >> a >> d >> b >> e)
{
month.push_back(c);
day.push_back(d);
year.push_back(e);
}
int len = year.size();
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
if (year[i] < year[j])
{
int temp1 =year [i];
year [i] =year [j];
year [j] = temp1;
int temp2 =month [i];
month [i] =month [j];
month[j] = temp2;
int temp =day [i];
day[i] =day [j];
day[j] = temp;
}
else if ((year[i] == year[j]) && (i != j) && (month[i] < month[j]))
{
int temp1 = year[i];
year[i] = year[j];
year[j] = temp1;
int temp2 = month[i];
month[i] = month[j];
month[j] = temp2;
int temp = day[i];
day[i] = day[j];
day[j] = temp;
}
else if ((year[i] == year[j]) && (i != j) && (month[i] == month[j]) && (day[i] < day[j]))
{
int temp1 = year[i];
year[i] = year[j];
year[j] = temp1;
int temp2 = month[i];
month[i] = month[j];
month[j] = temp2;
int temp = day[i];
day[i] = day[j];
day[j] = temp;
}
}
}
for (int i = 0; i < len; i++)
{
cout << setw(2) << setfill('0') <<month[i] << "/" << day[i] << "/" << year[i] << endl;
}
return 0;
}
c++日期排序
最新推荐文章于 2024-07-23 15:52:15 发布