Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string.h>
- using namespace std;
- int main()
- {
- int afisat = 0;
- struct
- {
- int a, l, z;
- } c[3];
- int i;
- cout<<"An: ";cin>>c[0].a;
- cout<<"Luna: ";cin>>c[0].l;
- cout<<"Ziua: ";cin>>c[0].z;
- cout<<"An: ";cin>>c[1].a;
- cout<<"Luna: ";cin>>c[1].l;
- cout<<"Ziua: ";cin>>c[1].z;
- if(c[0].a > c[1].a)
- {
- c[2].a = c[0].a-c[1].a;
- if(afisat == 0)
- {cout<<c[0].a<<"."<<c[0].l<<"."<<c[0].z; afisat = 1;}
- }
- else if(c[0].a < c[1].a)
- {
- c[2].a = c[1].a-c[0].a;
- if(afisat == 0)
- {cout<<c[1].a<<"."<<c[1].l<<"."<<c[1].z; afisat = 1;}
- }
- if(c[0].l > c[1].l)
- {
- c[2].l = c[0].l-c[1].l;
- if(afisat == 0)
- {cout<<c[0].a<<"."<<c[0].l<<"."<<c[0].z; afisat = 1;}
- }
- else if(c[0].l < c[1].l)
- {
- c[2].l = c[1].l-c[0].l;
- if(afisat == 0)
- {cout<<c[1].a<<"."<<c[1].l<<"."<<c[1].z; afisat = 1;}
- }
- if(c[0].z > c[1].z)
- {
- c[2].z = c[0].z-c[1].z;
- if(afisat == 0)
- {cout<<c[0].a<<"."<<c[0].l<<"."<<c[0].z; afisat = 1;}
- }
- else if(c[0].z < c[1].z)
- {
- c[2].z = c[1].z-c[0].z;
- if(afisat == 0)
- {cout<<c[1].a<<"."<<c[1].l<<"."<<c[1].z; afisat = 1;}
- }
- else
- {
- cout<<"Sunt Egale";
- }
- while(c[2].a > 1)
- {
- c[2].l+= 12;c[2].a--;
- }
- while(c[2].l > 1)
- {
- switch(c[2].l)
- {
- case 1: c[2].z += 31;
- case 2: c[2].z += 29;
- case 3: c[2].z += 31;
- case 4: c[2].z += 30;
- case 5: c[2].z += 31;
- case 6: c[2].z += 30;
- case 7: c[2].z += 31;
- case 8: c[2].z += 31;
- case 9: c[2].z += 30;
- case 10: c[2].z += 31;
- case 11: c[2].z += 30;
- case 12: c[2].z += 31;
- }
- c[2].l--;
- }
- cout<<"Diferenta in zile a celor doua dati este: "<<c[2].z;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement