Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct Fecha
- {
- int y, m, d;
- int getDays()
- {
- return d + m*31 + y*31*12;
- }
- };
- int main()
- {
- int tc;
- string a, b; ///ambas fechas
- cin >> tc;
- for(int i=0; i<tc; i++)
- {
- cin >> a >> b;
- Fecha f1, f2;
- f1.d = (a[0]-'0')*10 + (a[1]-'0');
- f1.m = (a[3]-'0')*10 + (a[4]-'0');
- f1.y = (a[6]-'0')*1000 + (a[7]-'0')*100 + (a[8]-'0')*10 + (a[9]-'0');
- f2.d = (b[0]-'0')*10 + (b[1]-'0');
- f2.m = (b[3]-'0')*10 + (b[4]-'0');
- f2.y = (b[6]-'0')*1000 + (b[7]-'0')*100 + (b[8]-'0')*10 + (b[9]-'0');
- if(f1.getDays() < f2.getDays())
- {
- cout << "Case #" << i+1 << ": Invalid birth date" << endl;
- }
- else
- {
- int age = (f1.y - f2.y - 1 + (f1.m > f2.m || (f1.m == f2.m && f1.d >= f2.d)));
- if(age > 130)
- {
- cout << "Case #" << i+1 << ": Check birth date" << endl;
- }
- else
- {
- cout << "Case #" << i+1 << ": " << age << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment