11219 - How old are you?
Moderator: Board moderators
Full code
[/code]
Code: Select all
#include <stdio.h>
#include <stdlib.h>
int casos;
int i;
int dia,mes,ano;
int dia2,mes2,ano2;
int resultado;
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);
}
}
Greater than 130?
Code: Select all
1
01/01/2031
02/01/1900
The judge accepts 130.
Thank You,
HG
Wrong Answer 11219!!!
Can someone help me to find the bug ?
I'm getting wrong answer with this simple problem...
Thank's a lot himanshu. I got AC.
I'm getting wrong answer with this simple problem...
Code: Select all
Removed after AC
Last edited by mukit on Thu Nov 22, 2007 6:12 pm, edited 1 time in total.
Re: Wrong Answer 11219!!!
Did you try this test case posted earlier in this thread?
Thank You,
HG
Code: Select all
1
01/02/1984
02/01/1984
HG
I try all case in this thread
but still got WA
Who can help me?
My code as follow
Thank's a lot helloneo
but still got WA
Who can help me?
My code as follow
Code: Select all
Removed after AC
Last edited by IRA on Mon Dec 03, 2007 11:50 am, edited 2 times in total.
Try this case..
My output..

Code: Select all
1
01/01/2004
01/02/2004
Code: Select all
Case #1: Invalid birth date

-
- Experienced poster
- Posts: 103
- Joined: Tue Mar 25, 2008 11:00 pm
- Location: IUT-OIC, DHAKA, BANGLADESH
- Contact:
Re: 11219 - How old are you?
thanx shiplu,,,,U r really boss.
I got AC.
Actually I am a great stupid.
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...............................
It is more tough to become a good person.
I am trying both...............................
-
- 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:
output should be
Good luck
input:
Code: Select all
2
28/2/2001
1/3/2001
29/2/2000
1/3/2000
Code: Select all
Case #1: Invalid birth date
Case #2: Invalid birth date
A learner......
-
- 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
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....
-
- 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
Output should be
Good luck 
Code: Select all
1
2/10/2000
2/11/1999
Code: Select all
Case #1: 0

A learner......
-
- New poster
- Posts: 9
- Joined: Thu Aug 21, 2008 3:08 am
- Location: IUT
Re: 11219 - How old are you?
Some one please help me to get Accepted.
I got WA for this problem.
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.
This may be the address of success.
-
- 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
Good luck

A learner......
Re: 11219 - How old are you?
Edited but still wA!!!
Code: Select all
removed
Last edited by Obaida on Sat Jan 10, 2009 11:50 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.