11219 - How old are you?
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11219 - How old are you?
Doesn't match the sample I/O
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 38
- Joined: Wed Dec 05, 2012 11:29 pm
Re: 11219 - How old are you?
@ brianfry713 : thanks for your reply. I checked all sample I/O and it is matched. Would you please mention which one is not match?
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11219 - How old are you?
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 38
- Joined: Wed Dec 05, 2012 11:29 pm
Re: 11219 - How old are you?
@ brianfry713 : I think there are some problem in this online compiler(https://ideone.com/raVomD)
I got wrong output for all of my code in this site. Even output is not same for all time in this online compiler
I got wrong output for all of my code in this site. Even output is not same for all time in this online compiler

-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11219 - How old are you?
I think there is a problem with your code.
Change line 11 from:
scanf("%d%/%d%/%d%d%/%d%/%d",&Dc,&Mc,&Yc,&Db,&Mb,&Yb);
to:
scanf("%d/%d/%d%d/%d/%d",&Dc,&Mc,&Yc,&Db,&Mb,&Yb);
Change line 11 from:
scanf("%d%/%d%/%d%d%/%d%/%d",&Dc,&Mc,&Yc,&Db,&Mb,&Yb);
to:
scanf("%d/%d/%d%d/%d/%d",&Dc,&Mc,&Yc,&Db,&Mb,&Yb);
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 38
- Joined: Wed Dec 05, 2012 11:29 pm
Re: 11219 - How old are you?
@ brianfry713: Finally I got AC
Thank You very much .

-
- New poster
- Posts: 38
- Joined: Wed Dec 05, 2012 11:29 pm
-
- New poster
- Posts: 6
- Joined: Sun Jul 21, 2013 1:36 pm
[11219 - How old are you?] Wrong Answer!! Plz help me
my code is below:
Code: Select all
#include <stdio.h>
int main(void)
{
int tC, i, cDD, cMM, cYY, bDD, bMM, bYY, day, month, year;
scanf("%d", &tC);
for(i=0; i<tC; i++)
{
scanf("%d/%d/%d", &cDD, &cMM, &cYY);
scanf("%d/%d/%d", &bDD, &bMM, &bYY);
if(cDD<bDD)
{
day = (cDD+30) - bDD;
cMM--;
}
else
day = cDD - bDD;
if(cMM<bMM)
{
month = (cMM+12) - bMM;
cYY--;
}
else
month = cMM - bMM;
year = cYY - bYY;
if(year<0)
printf("Case #%d: Invalid birth date\n", i+1);
else if(year>130)
printf("Case #%d: Check birth date\n", i+1);
else
printf("Case #%d: %d\n",i+1, year);
}
printf("\n");
return 0;
}
Re: [11219 - How old are you?] Wrong Answer!! Plz help me
marufsharif, correctly asked question is half of answer!
noone will be able to help you if they will not understand the problem,
that's why please, write about what your program does and define
the problem. Thx ).
noone will be able to help you if they will not understand the problem,
that's why please, write about what your program does and define
the problem. Thx ).
-
- New poster
- Posts: 6
- Joined: Sun Jul 21, 2013 1:36 pm
Re: [11219 - How old are you?] Wrong Answer!! Plz help me
@aybek
Thanks for your reply.
My problem is that my code [for 11219 - How old are you? problem] properly generate output as the problem is required.
But I'm failed every time when i submit my code, and i got wrong answer many times.
I get WA when i tried to print Last line with space and without space in my code.
I'm also test my code with various type of Data, as long as i observe, my code is correct. So why i get WA.
Please, help me for finding wrong with my code.
Thanks for your reply.
My problem is that my code [for 11219 - How old are you? problem] properly generate output as the problem is required.
But I'm failed every time when i submit my code, and i got wrong answer many times.

I get WA when i tried to print Last line with space and without space in my code.
I'm also test my code with various type of Data, as long as i observe, my code is correct. So why i get WA.

Please, help me for finding wrong with my code.
Re: [11219 - How old are you?] Wrong Answer!! Plz help me
If the output data of your program is valid but wasn't print in correct format, you won'tmarufsharif wrote: I get WA when i tried to print Last line with space and without space in my code.
get WA, you will get PE (Presentation Error)
try to give this input for your program:
1
05/01/2013
06/02/2012
your program output is:
Case #1: Invalid birth date
but it is not true answer. ). Sorry for my english.
Re: [11219 - How old are you?] Wrong Answer!! Plz help me
Code: Select all
#include <stdio.h>
struct date {
int day, month, year;
};
int main()
{
int Casenum;
scanf("%d", &Casenum);
struct date curr;
struct date born;
struct date diff;
int i;
for (i = 1; i <= Casenum; i++)
{
scanf("%d/%d/%d", &curr.day, &curr.month, &curr.year);
scanf("%d/%d/%d", &born.day, &born.month, &born.year);
diff.year = curr.year-born.year;
diff.month = curr.month-born.month;
diff.day = curr.day-born.day;
if (diff.year >= 0) {
if (diff.month < 0)
diff.year--;
else if (diff.month == 0)
if (diff.day < 0)
diff.year--;
}
printf("Case #%d: ", i);
if (diff.year < 0)
printf("Invalid birth date\n");
else if (diff.year > 130)
printf("Check birth date\n");
else
printf("%d\n", diff.year);
}
return 0;
}
more simple and easy to read. My advice for you: use structures.
Good luck in programming!

-
- New poster
- Posts: 6
- Joined: Sun Jul 21, 2013 1:36 pm
Re: [11219 - How old are you?] Wrong Answer!! Plz help me
@aybek
Thank you for your quick response.
Thank you for your quick response.

-
- New poster
- Posts: 1
- Joined: Tue Jan 01, 2013 7:41 pm
Re: [11219 - How old are you?] Wrong Answer!! Plz help me
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
using namespace std;
int main()
{
int cases,dd1,dd2,mm1,mm2,yy1,yy2,d,m,y,test=0;
cin>>cases;
while(cases != 0)
{
test++;
printf("\n");
scanf("%d/%d/%d%d/%d/%d",&dd1,&mm1,&yy1,&dd2,&mm2,&yy2);
if(dd1<dd2)
{
dd1 = dd1 + 30;
mm1--;
}
if(mm1<mm2)
{
mm1 = mm1 + 12;
yy1--;
}
d = dd1 - dd2;
m = mm1 - mm2;
y = yy1 - yy2;
if(y < 0)
{
printf("Case #%d: Invalid birth date\n",test);
}
else if(y > 130)
{
printf("Case #%d: Check birth date\n",test);
}
else
{
printf("Case #%d: %d\n",test,y);
}
cases--;
}
return 0;
}
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
using namespace std;
int main()
{
int cases,dd1,dd2,mm1,mm2,yy1,yy2,d,m,y,test=0;
cin>>cases;
while(cases != 0)
{
test++;
printf("\n");
scanf("%d/%d/%d%d/%d/%d",&dd1,&mm1,&yy1,&dd2,&mm2,&yy2);
if(dd1<dd2)
{
dd1 = dd1 + 30;
mm1--;
}
if(mm1<mm2)
{
mm1 = mm1 + 12;
yy1--;
}
d = dd1 - dd2;
m = mm1 - mm2;
y = yy1 - yy2;
if(y < 0)
{
printf("Case #%d: Invalid birth date\n",test);
}
else if(y > 130)
{
printf("Case #%d: Check birth date\n",test);
}
else
{
printf("Case #%d: %d\n",test,y);
}
cases--;
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: [11219 - How old are you?] Wrong Answer!! Plz help me
The output is comprised of one line for each input data set
Don't print extra blank lines.
Don't print extra blank lines.
Check input and AC output for thousands of problems on uDebug!