Page 3 of 8

Posted: Sat Jul 21, 2007 6:43 pm
by hamedv
can u pm me your full code???

Posted: Sat Jul 21, 2007 6:55 pm
by Pedro
Full 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);
        
        }
    
    
}
[/code]

Greater than 130?

Posted: Mon Oct 29, 2007 1:45 pm
by himanshu

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

Wrong Answer 11219!!!

Posted: Wed Nov 21, 2007 1:18 pm
by mukit
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.

Re: Wrong Answer 11219!!!

Posted: Wed Nov 21, 2007 2:00 pm
by himanshu
Did you try this test case posted earlier in this thread?

Code: Select all

1

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

Posted: Mon Dec 03, 2007 6:25 am
by IRA
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

Posted: Mon Dec 03, 2007 7:50 am
by helloneo
Try this case..

Code: Select all

1

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

Code: Select all

Case #1: Invalid birth date
:-)

Re: 11219 - How old are you?

Posted: Thu Sep 18, 2008 3:08 pm
by kbr_iut
thanx shiplu,,,,U r really boss.
I got AC.
Actually I am a great stupid.

Re: 11219 - How old are you?

Posted: Mon Sep 22, 2008 10:23 am
by shiplu_1320
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

Re: 11219 - How old are you?

Posted: Mon Sep 22, 2008 6:07 pm
by bleedingeyes
i got invalid for those input
but not AC yet

Code: Select all

//got AC

Re: 11219 - How old are you?

Posted: Mon Sep 22, 2008 10:03 pm
by shiplu_1320
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 :D

Re: 11219 - How old are you?

Posted: Tue Sep 23, 2008 1:42 pm
by bleedingeyes
thanks . i got AC now

Re: 11219 - How old are you?

Posted: Wed Jan 07, 2009 9:30 am
by Obaida
Some one please help me to get Accepted.
I got WA for this problem.

Code: Select all

removed

Re: 11219 - How old are you?

Posted: Wed Jan 07, 2009 11:12 am
by shiplu_1320
You are not printing newline in the output properly. check out it .........
Good luck :)

Re: 11219 - How old are you?

Posted: Sat Jan 10, 2009 8:15 am
by Obaida
Edited but still wA!!!

Code: Select all

removed