csansoon

P7.03 P71310 Scalar product

Nov 12th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. double scalar_product(const vector<double>& u, const vector<double>& v) {
  6.     double total=0;
  7.     for (int i=0; i< u.size() ; i++) total = total + (u[i]*v[i]);
  8.     return total;
  9. }
Add Comment
Please, Sign In to add comment