High_Light

Vektori 3.1

Mar 13th, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. //*https://habrahabr.ru/post/111071/
  2. //*https://ru.wikipedia.org/wiki/%D0%92%D0%B5%D0%BA%D1%82%D0%BE%D1%80%D0%BD%D0%BE%D0%B5_%D0%BF%D1%80%D0%BE%D0%B8%D0%B7%D0%B2%D0%B5%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5
  3.  
  4.  
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. class Vektor{
  10. public:
  11.     float x,y;
  12.     Vektor(float x_,float y_): x(x_), y(y_){}
  13.     void print(){
  14.         cout << x << "\t" << y << endl;
  15.     }
  16.     Vektor add (Vektor b){
  17.         return Vektor (x * b.x , y * b.y);
  18.     }
  19.     Vektor dot (Vektor b){
  20.        
  21.     }
  22. };
  23.  
  24. int main()
  25. {
  26.     Vektor a(1 ,2);
  27.     a.print();
  28.     Vektor b(3 ,4);
  29.     b.print();
  30.     Vektor c= a.add(b);
  31.     c.print();
  32. return 0;
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. #include <iostream>
  42.  
  43. using namespace std;
  44.  
  45. class Vektor{
  46. public:
  47.     float x,y,z;
  48.     Vektor(float x_,float y_,float z_): x(x_), y(y_), z(z_) {}
  49.     void print(){
  50.         cout << x << "\t" << y << "\t" << z << endl;
  51.     }
  52.     Vektor add (Vektor b){
  53.         return Vektor (x + b.x , y + b.y, z+b.z);
  54.     }
  55.     float dot (Vektor b){
  56.         float d= x*b.x + y*b.y + z*b.z;
  57.         return d;
  58.     }
  59.     Vektor cross(Vektor b){
  60.         return Vektor(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);
  61.     }
  62.  
  63. };
  64.  
  65. int main()
  66. {
  67.     Vektor a(2,0,0);
  68.     a.print();
  69.     Vektor b(0,2,0);
  70.     b.print();
  71.     Vektor c = a.cross(b);
  72.     c.print();
  73. return 0;
  74. }
Add Comment
Please, Sign In to add comment