Page 1 of 1

12541 - Birthdates

Posted: Fri May 16, 2014 2:09 pm
by uDebug
Here's some input / output I found useful during testing / debugging.

Input:

Code: Select all

10
Machel 31 12 4999
Amar 27 9 1991
Conrad 1 1 1999
Kara 18 9 5001
Tom 29 1 1991
Priyanka 1 12 5001
Melissa 25 10 1991
Ping 16 10 5001
Amidala 10 1 1991
Xena 17 10 5001
AC Output:

Code: Select all

Priyanka
Amidala

Re: 12541 - Birthdates

Posted: Mon Sep 08, 2014 8:52 pm
by battirunner

Code: Select all

why WA ?
#include<stdio.h>
#include<string.h>
int main()
{
int test,d,m,y,day,mn,mx,t;
char name[20],older[20],younger[20];
scanf("%d",&test);
t=test;
while(test--)
{
    scanf("%s",name);

    scanf("%d%d%d",&d,&m,&y);
    day=d+(31*m)+(y*12*31);
    if(test==t-1)
    {
        mn=day;
        mx=day;
        strcpy(older,name);
            strcpy(younger,name);
    }
    if(day<mx)
    {
        strcpy(older,name);
    mx=day;
    }
    else if(day>mn)
    {
       strcpy(younger,name);
       mn=day;
    }
}
printf("%s\n%s",younger,older);
return 0;
}
 :( 

Re: 12541 - Birthdates

Posted: Tue Sep 09, 2014 5:43 am
by brianfry713
Always print a newline char at the end of the last line.

Re: 12541 - Birthdates

Posted: Tue Sep 09, 2014 7:02 am
by battirunner
battirunner wrote:

Code: Select all

Thanks brainfry