Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. class Raum
  7. {
  8.     int x,y,z;
  9. public:
  10.  
  11.     Raum(int x,int y,int z)
  12.     {
  13.         this->x = x;
  14.         this->y = y;
  15.         this->z = z;
  16.     }
  17.  
  18.     Raum()
  19.     {
  20.         x = 0;
  21.         y = 0;
  22.         z = 0;
  23.     }
  24.  
  25.     void setter(int x,int y,int z)
  26.     {
  27.         this->x = x;
  28.         this->y = y;
  29.         this->z = z;
  30.     }
  31.     int dif_x(Raum &r)
  32.     {
  33.         int erg;
  34.         erg = x-r.x;
  35.         return erg;
  36.     }
  37.  
  38.     int dif_y(Raum &r)
  39.     {
  40.         int erg;
  41.         erg = y-r.y;
  42.         return erg;
  43.     }
  44.  
  45.     int dif_z(Raum &r)
  46.     {
  47.         int erg;
  48.         erg = z-r.z;
  49.         return erg;
  50.     }
  51.  
  52.     int get_x()
  53.     {
  54.         return x;
  55.     }
  56.  
  57.     Raum operator+(Raum &r)
  58.     {
  59.         Raum erg;
  60.         erg.x = x+r.x;
  61.         erg.y = y+r.y;
  62.         erg.z = z+r.z;
  63.         return erg;
  64.     }
  65. };
  66.  
  67. int main()
  68. {
  69.     int x,y,z;
  70.     Raum zahl1,zahl2;
  71.     cin>>x>>y>>z;
  72.     zahl1.setter(x,y,z);
  73.     cin>>x>>y>>z;
  74.     zahl2.setter(x,y,z);
  75.     x = zahl1.dif_x(zahl2);
  76.     y = zahl1.dif_y(zahl2);
  77.     z = zahl1.dif_z(zahl2);
  78.     string name;
  79.     cin>>name;
  80.     ofstream datei(name);
  81.     if(datei == NULL)
  82.     {
  83.         cout<<"ERROR";
  84.     }
  85.     else
  86.     {
  87.         datei<<x<<endl<<y<<endl<<z<<endl;
  88.         datei.close();
  89.     }
  90.     return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement