Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdio.h>
- #include <stdlib.h>
- using namespace std;
- typedef struct
- {
- unsigned z, l, a;
- } DATA;
- int main()
- {
- unsigned z1, z2;
- DATA d1, d2, rec;
- cout << "data 1:" << endl;
- cout << "-zi:";
- cin >> d1.z;
- cout << "-luna:";
- cin >> d1.l;
- cout << "-an:";
- cin >> d1.a;
- cout << "data 2:" << endl;
- cout << "-zi:";
- cin >> d2.z;
- cout << "-luna:";
- cin >> d2.l;
- cout << "-an:";
- cin >> d2.a;
- cout << endl;
- if (d1.a < d2.a)
- rec = d2;
- else if (d1.a > d2.a)
- rec = d1;
- else
- {
- if (d1.l < d2.l)
- rec = d2;
- else if (d1.l > d2.l)
- rec = d1;
- else
- {
- if (d1.z < d2.z)
- rec = d2;
- else
- rec = d1;
- }
- }
- cout << "cea mai recenta data(zz-ll-aa):" << rec.z << '-' << rec.l << '-' << rec.a << endl;
- z1 = (d1.a - 1) * 365 + (d1.l - 1) * 30 + d1.z;
- z2 = (d2.a - 1) * 365 + (d2.l - 1) * 30 + d2.z;
- cout << "diferenta in zile: " << abs(z1 - z2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement