-
Notifications
You must be signed in to change notification settings - Fork 1
/
uva_11219 how old are you.cpp
67 lines (61 loc) · 1.45 KB
/
uva_11219 how old are you.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int test_case,bdate,bmonth,byear,age,cdate,cmonth,cyear,cont=0;
char ch;
bool a,b,c;
cin>>test_case;
while(test_case--)
{
cont++;
a=0,b=0,c=0;
cin>>cdate>>ch>>cmonth>>ch>>cyear>>bdate>>ch>>bmonth>>ch>>byear;
if((cyear<byear) || (cyear==byear && cmonth<bmonth) || (cyear==byear && cmonth==bmonth && cdate<bdate))
{
a=1;
}
if(cyear>byear)
{
b=1;
if(cmonth==bmonth)
{
if(cdate>bdate)
{
age=cyear-byear;
}
else{age=(cyear-byear)-1;}
}
if(cmonth>bmonth)
{
age=cyear-byear;
}
if(cmonth<bmonth)
{
age=(cyear-byear)-1;
}
if(age>130)
{
b=0; c=1;
}
}
if(cyear==byear && cmonth==bmonth && cdate==bdate)
{
b=1;
a=c=age=0;
}
if(a)
{
printf("Case #%d: Invalid birth date\n",cont);
}
if(b)
{
printf("Case #%d: %d\n",cont,age);
}
if(c)
{
printf("Case #%d: Check birth date\n",cont);
}
}
}