Re: [11219 - How old are you?] Wrong Answer!! Plz help me
Posted: Mon Nov 18, 2013 12:10 pm
WA , Please Help
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",¤t_date,&slash,¤t_month,&slash,¤t_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;
}