Advertisement
Guest User

LB

a guest
Oct 25th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. class Spalva
  6. {
  7. private:
  8.     int R;
  9.     int G;
  10.     int B;
  11. public:
  12.  
  13.  
  14.     Spalva() { R = 0; G = 0; B = 0; }
  15.     Spalva(int R, int G, int B)
  16.     {
  17.         this->R = R;
  18.         this->G = G;
  19.         this->B = B;
  20.     }
  21.         Spalva(Spalva& s)
  22.     {
  23.         this->R = s.R;
  24.         this->G = s.G;
  25.         this->B = s.B;
  26.     }
  27.  
  28.     ~Spalva() {}
  29.  
  30.     Spalva Substract(Spalva s)
  31.     {
  32.         Spalva Rez(*this);
  33.         Rez.R = (Rez.R - s.R > 0) ? Rez.R - s.R : 0;
  34.         Rez.G = (Rez.G - s.G > 0) ? Rez.G - s.G : 0;
  35.         Rez.B = (Rez.B - s.B > 0) ? Rez.B - s.B : 0;
  36.         return Rez;
  37.     }
  38.  
  39.     void GetInput() {
  40.         cin >> R >> G >> B;
  41.     }
  42.     void GetOutput() {
  43.         cout << R << " " << G << " " << B << endl;
  44.     }
  45. };
  46. int main()
  47. {
  48.     Spalva spalva1;
  49.     Spalva spalva2;
  50.     Spalva spalva3(60, 70, 80);
  51.     Spalva spalva4(150, 180, 200);
  52.  
  53.     spalva1.GetInput();
  54.     spalva2.GetInput();
  55.     Spalva substract1 = spalva1.Substract(spalva3);
  56.     Spalva substract2 = spalva2.Substract(spalva4);
  57.     substract1.GetOutput();
  58.     substract2.GetOutput();
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement