Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- class Spalva
- {
- private:
- int R;
- int G;
- int B;
- public:
- Spalva() { R = 0; G = 0; B = 0; }
- Spalva(int R, int G, int B)
- {
- this->R = R;
- this->G = G;
- this->B = B;
- }
- Spalva(Spalva& s)
- {
- this->R = s.R;
- this->G = s.G;
- this->B = s.B;
- }
- ~Spalva() {}
- Spalva Substract(Spalva s)
- {
- Spalva Rez(*this);
- Rez.R = (Rez.R - s.R > 0) ? Rez.R - s.R : 0;
- Rez.G = (Rez.G - s.G > 0) ? Rez.G - s.G : 0;
- Rez.B = (Rez.B - s.B > 0) ? Rez.B - s.B : 0;
- return Rez;
- }
- void GetInput() {
- cin >> R >> G >> B;
- }
- void GetOutput() {
- cout << R << " " << G << " " << B << endl;
- }
- };
- int main()
- {
- Spalva spalva1;
- Spalva spalva2;
- Spalva spalva3(60, 70, 80);
- Spalva spalva4(150, 180, 200);
- spalva1.GetInput();
- spalva2.GetInput();
- Spalva substract1 = spalva1.Substract(spalva3);
- Spalva substract2 = spalva2.Substract(spalva4);
- substract1.GetOutput();
- substract2.GetOutput();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement