Advertisement
Guest User

11219 - How old are you?

a guest
Dec 14th, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include<cstdio>
  2. #include<iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9.     int day,month,year,age,t,day1,month1,year1,i;
  10.     char ch;
  11.     scanf("%d",&t);
  12.     i=0;
  13.     while(t--)
  14.     {
  15.         i++;
  16.         scanf("%d%c%d%c%d",&day,&ch,&month,&ch,&year);
  17.         scanf("%d%c%d%c%d",&day1,&ch,&month1,&ch,&year1);
  18.         age=year-year1;
  19.         if((month1>month)||((month==month1)&&(day<day1)))
  20.             age=age-1;
  21.         if(age<0)
  22.             cout<<"Case #"<<i<<":"<<" "<<"Invalid birth date"<<endl;
  23.         else if(age>130)
  24.             cout<<"Case #"<<i<<":"<<" "<<"Check birth date"<<endl;
  25.         else
  26.             cout<<"Case #"<<i<<":"<<" "<<age<<endl;
  27.  
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement