## 11219 - How old are you?

Moderator: Board moderators

hamedv
Learning poster
Posts: 98
Joined: Mon May 07, 2007 8:30 am
can u pm me your full code???

Pedro
New poster
Posts: 5
Joined: Fri Jul 20, 2007 5:18 pm
Full code

Code: Select all

``````#include <stdio.h>
#include <stdlib.h>

int casos;
int i;
int dia,mes,ano;
int dia2,mes2,ano2;

int VerificaBissexto(int b){
if (b%100!=0){
if (b%4==0){
return 1;
}else{
return 0;
}
}else{
if (b%400==0){
return 1;
}else{
return 0;
}
}

}

void CalculaAnos(int d1,int d2,int m1,int m2,int a1,int a2,int numCaso){
int m,a,d;

if (a1==a2){
if (m1>=m2){
if (m2==m1){
if (d1>=d2){
printf("Case #%d: 0",numCaso);
return;
}else{
printf("Case #%d: Invalid birth date",numCaso);
return;
}
}else{
printf("Case #%d: 0",numCaso);
return;
}

}else{
printf("Case #%d: Invalid birth date",numCaso);
return;
}
}else{
if (a1<a2){
printf("Case #%d: Invalid birth date",numCaso);
return;
}else{
if (m1>m2){
a=a1-a2;
}else{
if (m1==m2){
if (VerificaBissexto(a2)==1){
if (VerificaBissexto(a1)==0){
if ((d2==29)&&(d1==28)){
printf("Case #%d: 0",numCaso);
return;
}
}else{
if (d1<d2){
a=a1-a2-1;
printf("Case #%d: %d",numCaso,a);
return;
}
}
}

if (m2>m1){
a=a1-a2-1;
printf("Case #%d: %d",numCaso,a);
return;
}
if (d2<d1){
a=a1-a2;
}else{
if (d2!=d1){
a=a1-a2-1;
}else{
a=a1-a2;
}
}

}

}

}

}

if (a<=130){
printf("Case #%d: %d",numCaso,a);
}else{
printf("Case #%d: Check birth date",numCaso,a);
}

}

int main(){
scanf("%d",&casos);
for (i=1;i<=casos;i++){
printf("\n");
scanf("%d/%d/%d",&dia,&mes,&ano);
scanf("%d/%d/%d",&dia2,&mes2,&ano2);
CalculaAnos(dia,dia2,mes,mes2,ano,ano2,i);

}

}
``````
[/code]

himanshu
New poster
Posts: 17
Joined: Mon May 15, 2006 12:24 pm
Contact:

### Greater than 130?

Code: Select all

``````1

01/01/2031
02/01/1900 ``````
Shouldn't the above output "Check birth date" because the age is greater than 130 even though it is not 131 years.

The judge accepts 130.

Thank You,
HG

mukit
New poster
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Contact:

Can someone help me to find the bug ?
I'm getting wrong answer with this simple problem...

Code: Select all

``````Removed after AC
``````
Thank's a lot himanshu. I got AC.
Last edited by mukit on Thu Nov 22, 2007 6:12 pm, edited 1 time in total.

himanshu
New poster
Posts: 17
Joined: Mon May 15, 2006 12:24 pm
Contact:

Did you try this test case posted earlier in this thread?

Code: Select all

``````1

01/02/1984
02/01/1984 ``````
Thank You,
HG

IRA
Learning poster
Posts: 82
Joined: Sat Jan 07, 2006 6:52 am
I try all case in this thread
but still got WA
Who can help me?

My code as follow

Code: Select all

``Removed after AC ``
Thank's a lot helloneo
Last edited by IRA on Mon Dec 03, 2007 11:50 am, edited 2 times in total.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea
Try this case..

Code: Select all

``````1

01/01/2004
01/02/2004``````
My output..

Code: Select all

``Case #1: Invalid birth date``

kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Contact:

### Re: 11219 - How old are you?

thanx shiplu,,,,U r really boss.
I got AC.
Actually I am a great stupid.
Last edited by kbr_iut on Fri Sep 26, 2008 1:09 am, edited 1 time in total.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................

shiplu_1320
New poster
Posts: 32
Joined: Sat Dec 29, 2007 9:08 pm
Location: CSEDU , Dhaka
Contact:

### Re: 11219 - How old are you?

Kabir, try this,
input:

Code: Select all

``````2
28/2/2001
1/3/2001

29/2/2000
1/3/2000
``````
output should be

Code: Select all

``````Case #1: Invalid birth date
Case #2: Invalid birth date
``````
Good luck
A learner......

bleedingeyes
New poster
Posts: 9
Joined: Thu Aug 21, 2008 3:08 am
Location: IUT

### Re: 11219 - How old are you?

i got invalid for those input
but not AC yet

Code: Select all

``````//got AC
``````
Last edited by bleedingeyes on Tue Sep 23, 2008 1:43 pm, edited 1 time in total.
wanna be notorious....

shiplu_1320
New poster
Posts: 32
Joined: Sat Dec 29, 2007 9:08 pm
Location: CSEDU , Dhaka
Contact:

### Re: 11219 - How old are you?

you can try this

Code: Select all

``````1
2/10/2000
2/11/1999
``````
Output should be

Code: Select all

``````Case #1: 0
``````
Good luck
A learner......

bleedingeyes
New poster
Posts: 9
Joined: Thu Aug 21, 2008 3:08 am
Location: IUT

### Re: 11219 - How old are you?

thanks . i got AC now
wanna be notorious....

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11219 - How old are you?

I got WA for this problem.

Code: Select all

``removed``
Last edited by Obaida on Sat Jan 10, 2009 7:58 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

shiplu_1320
New poster
Posts: 32
Joined: Sat Dec 29, 2007 9:08 pm
Location: CSEDU , Dhaka
Contact:

### Re: 11219 - How old are you?

You are not printing newline in the output properly. check out it .........
Good luck
A learner......

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
``removed``