Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdexcept>
- #include <list>
- using namespace std;
- template <typename TipP1, typename TipP2>
- auto SkalarniProizvod (TipP1 It1, TipP1 It2, TipP2 It3)-> decltype(*It1)
- {
- decltype (*It1*(*It3)) sk_pr{0};
- while (It1!=It2) {
- sk_pr+=((*It1)*(*It3));
- It1++;
- It3++;
- }
- return sk_pr;
- }
- int main () {
- list<int> L1{1,2,3,4,5};
- list<int> L2{4,5,3,8,7};
- cout<<SkalarniProizvod(L1.begin(),L1.end(), L2.begin());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement