**Arrange the dates SOLUTION SSEC0004**

**Arrange the dates SOLUTION SSEC0004**

Compose a program to organize the dates of birth entered by client in climbing request. Given a number n, where n is the quantity of dates entered. Dates are in the organization Date/Month/Year.

*Valid date will be thought of!!

Info

The main line of the info contains a solitary number “n” meaning the quantity of dates.

The following line contains “n” dates .

Yield

Print the masterminded dates.

Imperatives

1 ≤n≤ 50

1 ≤Date≤ 31

1 ≤Month≤ 12

1 ≤ Year≤ Infinite

Experiments:

Model Input:

2

5/9/2010

2/3/2007

Model Output:

2/3/2007

5/9/2010

Model Input:

3

9/9/2008

8/9/2008

12/11/2006

Model Output:

12/11/2006

8/9/2008

9/9/2008

What does this Valid date is only considered mean?… I'm stuck at this.

Plus what should the output be displayed?(each line or space separated)

Hey, I hope your doing great.

We are really sorry that till now we didn't update some questions with it's logic. We are facing some issues once it's resolve we will update the LOGICS!!.

Here's your Answer.

If you read the question one thing is clear that we are going to do sorting over here but exactly where is it on date? Month? or Year?. If you apply sorting on Date then it's very very easy to complete the solution HOLD ON! are we even reading the Second Example Output given in the Question.

Example Input:

3

9/9/2008

8/9/2008

12/11/2006

Now as per our theory if we sort them based on Date then it's easy but check the output below.

Example Output:

12/11/2006

8/9/2008

9/9/2008

Here we see that Date sorting theory completely fails but we also got our answer that we do not have to do Sorting for DATE and MONTH. So, it's clear that we need to sort based on YEAR.

I hope this is clear now that how the output will Occur.

Now, Let's jump into the question and see what it want's from us.

If we see the constraints,

Constraints

1 ≤n≤ 50

1 ≤Date≤ 31

1 ≤Month≤ 12

1 ≤ Year≤ Infinite

The question is why in this format why not something else, to confirm that read the question end point it says, "*Valid date will be considered!!" Now this makes it clear why the constraints is in that format we need to get valid dates.

For Example :

2019/2/29 ( What are we doing here look at the date Feb 29 which is not possbile because the year is not a Leap Year here)

I hope that clears out this statement "*Valid date will be considered!!"

Now we saw few things here

1.We need to figure out the valid dates

2. Keeping in mind that some years can be leap year

3.If the dates are valid then only it will be consider

4.Once you get the right Dates then print them based on its Year.

5. Remember no Sorting on DATE or MONTH it will give wrong answer.

Let's finish this off with some examples.

Input : 6

29/2/2019

28/2/2019

2/1/2006

29/2/2012

29/2/2016

5/3/2001

What a fascinating inputs isn't it.

Output :

5/3/2001

2/1/2006

29/2/2012

29/2/2016

28/2/2019

Now we can see that 29/2/2019 is not a valid date because its not a leap year.

Now we also see that 29/2/2012 and 29/2/2016 is accepted because those are leap years.

What can we do? We need to know how to take valid input of years in leap year then How can we sort them up based on its year and print the output.

I hope this clear's everyone's doubt.

KEEP CODING GUYS…

I'm doing exactly the same still WA. For your sample test cases as well it's printing correctly!

Okay, have you tried various inputs? if they are coming correctly then the problem might be in constraints Like we can't have 0 date or 13 month something like that and if your still facing the same issue even tho the constraints are correct, then check your code once maybe it could have some errors.

Can you give few examples of invalid date formats other than leap year concept? I've tried with everything but it's giving me WA everytime I submit!

Okay so some invalid dates:

17/02/2020

31/9/2020

01/01/2019

06/07/2012

15/13/2000

You can see that the month input should be 2 not /02/ and even the date it should be 1 not 01/

Ok this point I didn't check… Thnx I'll incorporate this as well!

Btw are these years : 1, 20, 101, 20013 valid? (I mean can years be of different number of digits than 4… eg: year 1 has 1digit, 20013 has 5 digits)

Year 1 AD was not called that during that time period, if that's what you mean. The current year system that places the year 0001 at 2,014 years ago was invented in the 6th century, so people who were living in the "year 0001" did not know it would one day be called the year 0001.

So we can see it can be 0001. 0002 or 0087

#include

int main()

{

int n;

scanf("%d",&n);

int d[n];

int m[n];

int y[n];

for(int i=0;iy[j]){

int temp1=y[i];

y[i]=y[j];

y[j]=temp1;

}

if(m[i]>m[j]){

int temp2=m[i];

m[i]=m[j];

m[j]=temp2;

}

if(d[i]>d[j]){

int temp3=d[i];

d[i]=d[j];

d[j]=temp3;

}

}

}

for(int i=0;i<n;i++)

printf("%d/%d/%dn",d[i],m[i],y[i]);

}