Arrange the dates - SSEC0004

Problem Link: SSEC0004

Problem:

Write a program to arrange the dates of birth entered by user in ascending order. Given an integer n, where n is the number of dates entered. Dates are in the format Date/Month/Year .

*Valid date will be considered!!

Input
The first line of the input contains a single integer “n” denoting the number of dates.
The next line contains “n” dates . Output
Print the arranged dates. Constraints
1 ≤n≤ 50
1 ≤Date≤ 31
1 ≤Month≤ 12
Year can be anything. Test Cases:
Example Input:
2
5/9/2010
2/3/2007

Example Output:
2/3/2007
5/9/2010

Example Input:
3
9/9/2008
8/9/2008
12/11/2006

Example Output:
12/11/2006
8/9/2008
9/9/2008

Solution:

#include <bits/stdc++.h>
#define int long long
#define vi vector
#define vvi vector<vector>
#define pb push_back
#define For(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define MAX 100005
#define MAX2 10000
#define endl ‘\n’
#define Sort(v) sort(v.begin(), v.end())
using namespace std;
void show(int a[MAX], int n)
{
For(i,n)
cout<<a[i]<<" “;
cout<<”\n";
}

void show1(int a[MAX2][MAX2], int r, int c)
{
For(i,r)
{
For(j,c)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
}

bool check(vi a ,int k)
{
For(i,a.size())
{
if (a[i] == k)
return true;
}
return false;
}
void show(vector a)
{
for(int i=0;i<a.size();i++)
cout<<a[i]<<" “;
cout<<endl;
}
void show(vector a)
{
for(int i=0;i<a.size();i++)
cout<<a[i]<<” “;
cout<<endl;
}
void show(vector<vector> a)
{
for(int i=0;i<a.size();i++)
{
for(int j=0;j<a[i].size()-1;j++)
{
cout<<a[i][j]<<”/";
}
cout<<a[i][2]<<endl;
}
}

int32_t main()
{
int t,s;
char c;
vector a;
vector<vector> a1;
cin>>t;
while(t–)
{
a.clear();
cin>>s;
cin>>c;
a.push_back(s);
cin>>s;
cin>>c;
a.push_back(s);
cin>>s;
a.push_back(s);
a1.push_back(a);
}
// show(a1);
for(int i=0;i<a1.size();i++)
{
for(int j=i+1;j<a1.size();j++)
{
if(a1[i][2] > a1[j][2])
{
a = a1[i];
a1[i] = a1[j];
a1[j] = a;
}
if (a1[i][2] == a1[j][2])
{
if(a1[i][1] > a1[j][1])
{
a = a1[i];
a1[i] = a1[j];
a1[j] = a;
}
if (a1[i][1] == a1[j][1])
{
if(a1[i][0] > a1[j][0])
{
a = a1[i];
a1[i] = a1[j];
a1[j] = a;
}
}
}
}
}
show(a1);
}