Guest User

Untitled

a guest
Apr 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4. double producte_escalar (int n, vector <double>& v1, vector <double>& v2){
  5.         int prod=0;
  6.         for (int i=0; i<n; ++i){
  7.                 for (int j=0; j<n; ++j){
  8.                         prod=prod + (v1[i] * v2[j]);
  9.                 }
  10.         }
  11.         return prod;
  12. }
  13. int main(){
  14.         double n;
  15.         cin >> n;
  16.         vector<double> v1(n);
  17.         vector<double> v2(n);
  18.         for(int i=0; i<n; ++i) cin >> v1[i];
  19.         for(int j=0; j<n; ++j) cin >> v2[j];
  20.         double prod=producte_escalar (n,v1,v2);
  21.         {cout << prod << endl;}
  22. }
Add Comment
Please, Sign In to add comment