Page 7 of 8

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Mon Nov 18, 2013 12:10 pm

Code: Select all

``````#include<cstdio>
#include<iostream>

using namespace std;

int test_case,age,flag,i=1;
int birth_date,birth_month,current_date,current_month;
int calculate_age();
long long birth_year,current_year;

int main()
{
char slash;
scanf("%d",&test_case);
while(i<=test_case)
{
flag=0;
scanf("%d%c%d%c%lld",&current_date,&slash,&current_month,&slash,&current_year);
scanf("%d%c%d%c%lld",&birth_date,&slash,&birth_month,&slash,&birth_year);
if(current_year<birth_year)
{
printf("Case %d: Invalid birth date",i);
}
else if(current_year==birth_year)
{
if(current_month>=birth_month)
{
if(current_date<=birth_date)
{
age=calculate_age();
flag=1;
}
else
{
printf("Case %d: Invalid birth date",i);
}
}
else
{
printf("Case %d: Invalid birth date",i);
}
}
else
{
flag=1;
age=calculate_age();
if(current_month==birth_month)
{
if(current_date<birth_date)
age--;
}
if(current_month<birth_month)
{
age--;
}

}
if(flag==1)
{
if(age>=130)
printf("Case %d: Check birth date",i);
else
printf("Case %d: %d",i,age);
}
i++;

}
return 0;
}

int calculate_age()
{
return current_year-birth_year;
}

``````

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Mon Nov 18, 2013 10:54 pm
Print a newline char at the end of each line.

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Tue Nov 19, 2013 1:52 pm
Why should I ?
Can u tell me the reason.
Still WA

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Wed Nov 20, 2013 1:47 am
For the sample input, the correct output is:

Code: Select all

``````Case #1: Invalid birth date
Case #2: Check birth date
Case #3: 23
Case #4: 0
``````

Code: Select all

``````Case 1: Invalid birth dateCase 2: Check birth dateCase 3: 23Case 4: 0
``````
Your output is wrong. Post your updated code if you're still having trouble.

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Wed Nov 20, 2013 7:47 am
Code Updated

Code: Select all

``````
#include<cstdio>
#include<iostream>

using namespace std;

int test_case,age,flag,i=1;
int birth_date,birth_month,current_date,current_month;
int calculate_age();
long long birth_year,current_year;

int main()
{
char slash;
scanf("%d",&test_case);
while(i<=test_case)
{
flag=0;
scanf("%d%c%d%c%lld",&current_date,&slash,&current_month,&slash,&current_year);
scanf("%d%c%d%c%lld",&birth_date,&slash,&birth_month,&slash,&birth_year);
if(current_year<birth_year)
{
printf("Case #%d: Invalid birth date\n",i);
}
else if(current_year==birth_year)
{
if(current_month>=birth_month)
{
if(current_date<=birth_date)
{
age=calculate_age();
flag=1;
}
else
{
printf("Case #%d: Invalid birth date\n",i);
}
}
else
{
printf("Case #%d: Invalid birth date\n",i);
}
}
else
{
flag=1;
age=calculate_age();
if(current_month==birth_month)
{
if(current_date<birth_date)
age--;
}
if(current_month<birth_month)
{
age--;
}

}
if(flag==1)
{
if(age>=130)
printf("Case #%d: Check birth date\n",i);
else
printf("Case #%d: %d\n",i,age);
}
i++;

}
return 0;
}

int calculate_age()
{
return current_year-birth_year;
}

``````

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Wed Nov 20, 2013 11:03 pm
Input:

Code: Select all

``````1

01/02/2130
01/01/2000
``````
Output should be:

Code: Select all

``````Case #1: 130
``````

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Thu Nov 21, 2013 12:04 pm
Still WA

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Thu Nov 21, 2013 8:37 pm
The code that you posted is still printing the wrong answer for the input I posted. Post your updated code if you want more help.

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Sun Nov 24, 2013 10:04 am
Code Updated

Code: Select all

``````#include<cstdio>
#include<iostream>

using namespace std;

int test_case,age,flag,i=1;
int birth_date,birth_month,current_date,current_month;
int calculate_age();
long long birth_year,current_year;

int main()
{
char slash;
scanf("%d",&test_case);
while(i<=test_case)
{
flag=0;
scanf("%d%c%d%c%lld",&current_date,&slash,&current_month,&slash,&current_year);
scanf("%d%c%d%c%lld",&birth_date,&slash,&birth_month,&slash,&birth_year);
if(current_year<birth_year)
{
printf("Case #%d: Invalid birth date\n",i);
}
else if(current_year==birth_year)
{
if(current_month>=birth_month)
{
if(current_date<=birth_date)
{
age=calculate_age();
flag=1;
}
else
{
printf("Case #%d: Invalid birth date\n",i);
}
}
else
{
printf("Case #%d: Invalid birth date\n",i);
}
}
else
{
flag=1;
age=calculate_age();
if(current_month==birth_month)
{
if(current_date<birth_date)
age--;
}
if(current_month<birth_month)
{
age--;
}

}
if(flag==1)
{
if(age>130)
printf("Case #%d: Check birth date\n",i);
else
printf("Case #%d: %d\n",i,age);
}
i++;

}
return 0;
}

int calculate_age()
{
return current_year-birth_year;
}

``````

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Tue Nov 26, 2013 11:42 pm
Input:

Code: Select all

``````1

01/01/2000
02/01/2000
``````
Correct output:

Code: Select all

``````Case #1: Invalid birth date
``````

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Mon Dec 02, 2013 9:56 am
AC , thanks bryanfry

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Tue Dec 03, 2013 9:01 pm
Hello, Getting WA. Can someone tell me why ?

Code: Select all

``````#include<stdio.h>
int main()
{
int x1,y1,z1,x2,y2,z2,test,i;
long int day,age;
scanf("%d",&test);
for(i=1;i<=test;i++)
{
printf("\n");
scanf("%d/%d/%d",&x1,&y1,&z1);
scanf("%d/%d/%d",&x2,&y2,&z2);
day=(x1+(y1-1)*30+z1*365)-(x2+(y2-1)*30+z2*365);
if(day<0)
printf("Case #%d: Invalid birth date\n",i);
else
{
age=(day-day%365)/365;
if(age>130)
printf("Case #%d: Check birth date\n",i);
else
printf("Case #%d: %ld\n",i,age);
}
}
return 0;
}
``````

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Wed Dec 04, 2013 12:03 am
The output is comprised of one line for each input data set, don't print extra blank lines.

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Sat Dec 14, 2013 5:20 pm

Code: Select all

``````#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n,dd1,mm1,yy1,dd2,mm2,yy2,days1,days2,old,check=1;
cin>>n;
while(n>0)
{
cout<<endl;
cin>>dd1;
cin.ignore();
cin>>mm1;
cin.ignore();
cin>>yy1;
days1=(yy1*365)+(mm1*30)+dd1;
cin>>dd2;
cin.ignore();
cin>>mm2;
cin.ignore();
cin>>yy2;
days2=(yy2*365)+(mm2*30)+dd2;
//cout<<endl;
if(days2>days1)
{
cout<<"Case #"<<check<<": "<<"Invalid birth date"<<endl;
}
else
{
old=(days1-days2)/365;
if(old>130)
{
cout<<"Case #"<<check<<": "<<"Check birth date"<<endl;
}
else
cout<<"Case #"<<check<<": "<<old<<endl;
}

check++;
n--;
}

return 0;
}``````

### Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Posted: Sat Dec 14, 2013 9:40 pm
Why you are printing an extra line at the beginning of every test case. You don't need that. Check output format carefully. Hope its helps .