#include <iostream>
#include <math.h>
using namespace std;
class wektor
{
private:
double x,y,z;
public:
void toString();
wektor();
wektor(double,double,double);
wektor operator+(wektor&);
double operator*(wektor&);
wektor operator/(wektor&);
};
wektor::wektor()
{
x=1;
y=1;
z=1;
}
wektor::wektor(double x,double y,double z)
{
this->x=x;
this->y=y;
this->z=z;
}
void wektor::toString()
{
cout<<"x="<<x<<" y="<<y<<" z="<<z<<endl;
}
wektor wektor::operator+(wektor&k)
{
wektor tmp;
tmp.x=this->y+k.x;
tmp.y=this->y+k.y;
tmp.z=this->z+k.z;
return tmp;
}
double wektor::operator*(wektor&k)
{
return this->x*k.x + this->y*k.y + this->z*k.z;
}
wektor wektor:: operator/(wektor&k)
{
wektor tmp;
tmp.x=this->y*k.z-this->z*k.y;
tmp.y=this->x*k.z-this->z*k.x;
tmp.z=this->x*k.y-this->y*k.x;
return tmp;
}
int main()
{
wektor a,b(2,2,2),c,d;
a.toString();
b.toString();
c=a+b;
cout<<"suma: ";
c.toString();
cout <<"iloczyn skalarany: "<<a*b << "\tstopnie: " <<atan(a*b)*(180.0/M_PI)<<endl;
d=a/b;
cout<<"iloczyn wektorowy: ";
d.toString();
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}