Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <conio.h>
  4. #include <cmath>
  5. using namespace std;
  6. class vector{
  7. public:
  8. double x,y,z;
  9. void set();
  10. void show();
  11. vector add(vector);
  12. double mod();
  13.  
  14. };
  15. void main(){
  16. setlocale(LC_ALL, "russian");
  17. vector A;
  18. vector B;
  19. B.x=4;
  20. B.y=-5;
  21. B.z=6;
  22. A.set();
  23. A.show();
  24. B.show();
  25. vector C=A.add(B);
  26. C.show();
  27. A.add(B).show();
  28. C.add(A).show();
  29. cout<<C.mod()<<endl;
  30. double c_mod=C.mod();
  31. cout<<c_mod<<endl;
  32. system("pause");
  33. }
  34. double vector::mod(){
  35. double otvet;
  36. otvet = sqrt(x*x+y*y+z*z);
  37. return otvet;
  38. }
  39. vector vector::add(vector B){
  40. vector otvet;
  41. otvet.x=x+B.x;
  42. otvet.y=y+B.y;
  43. otvet.z=z+B.z;
  44. return otvet;
  45. }
  46. void vector::set(){
  47. cin>>x>>y>>z;
  48. }
  49. void vector::show(){
  50. cout<<"{"<<x<<";"<<y<<";"<<z<<"}"<<endl;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement