Advertisement
Gireada

Tema nr.18

Nov 14th, 2013
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int afisat = 0;
  10.     struct
  11.     {
  12.             int a, l, z;
  13.     } c[3];
  14.     int i;
  15.     cout<<"An: ";cin>>c[0].a;
  16.     cout<<"Luna: ";cin>>c[0].l;
  17.     cout<<"Ziua: ";cin>>c[0].z;
  18.     cout<<"An: ";cin>>c[1].a;
  19.     cout<<"Luna: ";cin>>c[1].l;
  20.     cout<<"Ziua: ";cin>>c[1].z;
  21.     if(c[0].a > c[1].a)
  22.     {
  23.         c[2].a = c[0].a-c[1].a;
  24.         if(afisat == 0)
  25.             {cout<<c[0].a<<"."<<c[0].l<<"."<<c[0].z; afisat = 1;}
  26.     }
  27.     else if(c[0].a < c[1].a)
  28.     {
  29.         c[2].a = c[1].a-c[0].a;
  30.         if(afisat == 0)
  31.             {cout<<c[1].a<<"."<<c[1].l<<"."<<c[1].z; afisat = 1;}
  32.     }
  33.     if(c[0].l > c[1].l)
  34.     {
  35.         c[2].l = c[0].l-c[1].l;
  36.         if(afisat == 0)
  37.             {cout<<c[0].a<<"."<<c[0].l<<"."<<c[0].z; afisat = 1;}
  38.     }
  39.     else if(c[0].l < c[1].l)
  40.     {
  41.         c[2].l = c[1].l-c[0].l;
  42.         if(afisat == 0)
  43.             {cout<<c[1].a<<"."<<c[1].l<<"."<<c[1].z; afisat = 1;}
  44.     }
  45.     if(c[0].z > c[1].z)
  46.     {
  47.         c[2].z = c[0].z-c[1].z;
  48.         if(afisat == 0)
  49.             {cout<<c[0].a<<"."<<c[0].l<<"."<<c[0].z; afisat = 1;}
  50.     }
  51.     else if(c[0].z < c[1].z)
  52.     {
  53.         c[2].z = c[1].z-c[0].z;
  54.         if(afisat == 0)
  55.             {cout<<c[1].a<<"."<<c[1].l<<"."<<c[1].z; afisat = 1;}
  56.     }
  57.     else
  58.     {
  59.         cout<<"Sunt Egale";
  60.     }
  61.     while(c[2].a > 1)
  62.     {
  63.         c[2].l+= 12;c[2].a--;
  64.     }
  65.     while(c[2].l > 1)
  66.     {
  67.         switch(c[2].l)
  68.         {
  69.             case 1: c[2].z += 31;
  70.             case 2: c[2].z += 29;
  71.             case 3: c[2].z += 31;
  72.             case 4: c[2].z += 30;
  73.             case 5: c[2].z += 31;
  74.             case 6: c[2].z += 30;
  75.             case 7: c[2].z += 31;
  76.             case 8: c[2].z += 31;
  77.             case 9: c[2].z += 30;
  78.             case 10: c[2].z += 31;
  79.             case 11: c[2].z += 30;
  80.             case 12: c[2].z += 31;
  81.         }
  82.         c[2].l--;
  83.     }
  84.     cout<<"Diferenta in zile a celor doua dati este: "<<c[2].z;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement