Created
July 17, 2017 09:43
-
-
Save na5imuzzaman/457a0463fe2d49d8d8554a1015ec1848 to your computer and use it in GitHub Desktop.
UVa --> 11219 - How old are you?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Nasim */ | |
#include<bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
int day,month,year; | |
int day1,month1,year1; | |
int n,k=0,age; | |
cin>>n; | |
while (n != k++) | |
{ | |
scanf("%d/%d/%d",&day,&month,&year); | |
scanf("%d/%d/%d",&day1,&month1,&year1); | |
int total_day = day+(month*30); | |
int total_day1 = day1+(month1*30); | |
if (year == year1) | |
{ | |
if (total_day>=total_day1) | |
printf("Case #%d: 0\n",k); | |
else if(total_day<total_day1) | |
printf("Case #%d: Invalid birth date\n",k); | |
} | |
else if (year<year1) | |
{ | |
printf("Case #%d: Invalid birth date\n",k); | |
} | |
else if (year>year1) | |
{ | |
if (total_day>=total_day1) | |
{ | |
age = year-year1; | |
if (age>130) | |
printf("Case #%d: Check birth date\n",k); | |
else if (age>=0&&age<=130) | |
printf("Case #%d: %d\n",k,age); | |
} | |
else if(total_day<total_day1) | |
{ | |
age = year-year1; | |
age--; | |
if (age>130) | |
printf("Case #%d: Check birth date\n",k); | |
else if (age>=0&&age<=130) | |
printf("Case #%d: %d\n",k,age); | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment