#include <iostream>
#include <cmath>

using namespace std;

struct Vector{
	float x,y,z;
	Vector(float x, float y, float z)
		:x(x), y(y), z(z)
	{
		cout << "Vyroba" << endl;
	}
	~Vector()
	{
		cout << "Zanik" << endl;
	}

	Vector(const Vector &v)
	{
		*this = v;
		cout << "Kopia" << endl;
	}

	float length() const {
		return sqrtf(x*x + z*z + y*y);
	}

	Vector operator+(const Vector &b) const
	{
		return Vector(x + b.x, y + b.y, z + b.z);
	}

	Vector operator-() const {
	
		return Vector(-x,-y,-z);
	}

	bool operator==(const Vector &v) const {
		return (x == v.x && y == v.y && z == v.z);
	}
	bool operator!=(const Vector &v) const {
		return !(*this==v);
	}
	
	Vector& operator=(const Vector &v){
                x=v.x;
		y=v.y;
		z=v.z;
		return *this;
	}
	Vector& operator+=(const Vector &v){
                x+=v.x;
		y+=v.y;
		z+=v.z;
		return *this;
	}

	Vector operator*(float a) const {
		return Vector(a*x, a*y, a*z);
	}

	friend Vector operator*(float a, const Vector &v)
	{
		return v*a;
	}
};

std::ostream& operator << (std::ostream &out,const Vector &v) {
	return out<<v.x<<","<<v.y<<","<<v.z;
}


template <typename T>
void Swap(T &a, T &b)
{
	T temp = a;
	a = b;
	b = temp;
}

void Swap(int &a, int &b)
{
	cout <<"intovy swap!!!"<<std::endl;
	int temp = a;
	a = b;
	b = temp;
}


void f(Vector v)
{
	cout << "ve f: " << v << endl;
}

int main() {
	Vector v(4,2,1);
	cout << v.length() << endl;
	v = 2*(v + v);
	f(v);
	cout << v << endl;
#if 0
	int a, b;
	cin >> a >> b;

	Swap(a, b);
	cout << a << ' ' << b << '\n';
#endif

	return 0;

}
