11219 - How old are you?
Moderator: Board moderators
Try the cases.
Input:
Output:
Hope these help.
Input:
Code: Select all
7
29/02/2008
29/02/2000
28/02/2008
29/02/2000
01/03/2008
29/02/2000
01/03/2001
29/02/2000
28/02/2001
29/02/2000
29/02/2000
29/02/2000
29/02/2000
28/02/2000
Code: Select all
Case #1: 8
Case #2: 7
Case #3: 8
Case #4: 1
Case #5: 0
Case #6: 0
Case #7: 0
Ami ekhono shopno dekhi...
HomePage
HomePage
One more case that all tests above didn't cover and which was breaking my code follows:
Input:
Output:
Input:
Code: Select all
1
05/06/2031
06/06/1900
Code: Select all
Case #1: 130
UFCG Brazil - Computer Science graduate student
http://acm.uva.es/problemset/usersnew.php?user=54806 ... and going up!
http://acm.uva.es/problemset/usersnew.php?user=54806 ... and going up!
getting WA
I am getting WA .. I tried all inputs in the forum
Thanks in advanced

Code: Select all
Deleted after AC
Time that gone is gone forever ...
Plz tell me whats wrong in my code, it gives correct answer for all the i/o above.....

Code: Select all
#include<stdio.h>
#include<math.h>
void main()
{
long d,m,y,d1,m1,y1,d2,m2,y2,a,b,c,i,j,k,test,t;
char cy,cur[12],bir[12],ch,c1,c2,c3;
scanf("%ld",&test);
ch=getchar();
for(t=1;t<=test;t++)
{
cy=getchar();
gets(cur);
gets(bir);
sscanf(cur,"%ld%c%ld%c%ld",&d1,&c1,&m1,&c2,&y1);
sscanf(bir,"%ld%c%ld%c%ld",&d2,&c1,&m2,&c2,&y2);
y=y1-y2;
m=m1-m2;
d=d1-d2;
printf("Case #%ld: ",t);
if(y<0 ||(y==0 && m<0)||(y==0 && m==0 && d<0))
printf("Invalid birth date\n");
else if(y==0 && m>=0 && d>=0)
printf("0\n");
else if(y>0)
{
if(m>0 ||(m==0 && d>=0))
{
if(y>130)
printf("Check birth date\n");
else
printf("%ld\n",y);
}
else if(m<0 ||(m==0 && d<0))
{ y--;
if(y>130)
printf("Check birth date\n");
else
printf("%ld\n",y);
}
else
printf("0\n");
}
}
}
Somebody help me
Try this test case
----
Rio
Code: Select all
1
01/02/1984
02/01/1984
Rio
-
- Learning poster
- Posts: 74
- Joined: Sat Jul 15, 2006 6:28 am
- Location: CUET , bangladesh
- Contact:
i am WA.But Why? Please help me???
Code: Select all
Cut after AC
Last edited by shakil on Fri Jul 06, 2007 9:27 pm, edited 1 time in total.
SHAKIL
I tried all the inputs given and the outputs are correctly, but I got WA
I don't know where my code is wrong. Any idea?
I don't know where my code is wrong. Any idea?
Code: Select all
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);
}
}