Dvortsov_D1

crfkzhyjt g

Mar 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class vector{
  5. public:
  6.     float x;
  7.     float y;
  8. public:
  9.     vector (float x_,float y_) : x(x_), y(y_) { }
  10.     void print(){
  11.         cout << x << '\t' << y << endl;
  12.     }
  13.     vector add(vector b){
  14.         return vector(x * b.x, y * b.y);
  15.     }
  16.     float dot (vector b){
  17.         float v = x*b.x + y*b.y;
  18.         return v;
  19.     }
  20. };
  21.  
  22.  
  23. int main()
  24. {
  25.     vector a(1, 2);
  26.     a.print();
  27.     vector bbbb(4, 5);
  28.     bbbb.print();
  29.     vector c = a.add(bbbb);
  30.     c.print();
  31.     cout << a.dot(bbbb) << endl;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment