Advertisement
sellmmaahh

popravni-sept-2014-zad6

Jul 30th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdexcept>
  3. #include <list>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. template <typename TipP1, typename TipP2>
  9. auto SkalarniProizvod (TipP1 It1, TipP1 It2, TipP2 It3)-> decltype(*It1)
  10. {
  11.     decltype (*It1*(*It3)) sk_pr{0};
  12.     while (It1!=It2) {
  13.         sk_pr+=((*It1)*(*It3));
  14.         It1++;
  15.         It3++;
  16.     }
  17.     return sk_pr;
  18. }
  19. int main () {
  20. list<int> L1{1,2,3,4,5};
  21. list<int> L2{4,5,3,8,7};
  22. cout<<SkalarniProizvod(L1.begin(),L1.end(), L2.begin());
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement