Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <conio.h>
- #include <cmath>
- using namespace std;
- class vector{
- public:
- double x,y,z;
- void set();
- void show();
- vector add(vector);
- double mod();
- };
- void main(){
- setlocale(LC_ALL, "russian");
- vector A;
- vector B;
- B.x=4;
- B.y=-5;
- B.z=6;
- A.set();
- A.show();
- B.show();
- vector C=A.add(B);
- C.show();
- A.add(B).show();
- C.add(A).show();
- cout<<C.mod()<<endl;
- double c_mod=C.mod();
- cout<<c_mod<<endl;
- system("pause");
- }
- double vector::mod(){
- double otvet;
- otvet = sqrt(x*x+y*y+z*z);
- return otvet;
- }
- vector vector::add(vector B){
- vector otvet;
- otvet.x=x+B.x;
- otvet.y=y+B.y;
- otvet.z=z+B.z;
- return otvet;
- }
- void vector::set(){
- cin>>x>>y>>z;
- }
- void vector::show(){
- cout<<"{"<<x<<";"<<y<<";"<<z<<"}"<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement