Advertisement
sellmmaahh

TP-tut5-zad6

Sep 3rd, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. template <typename TipPok>
  9. auto SumaBloka(TipPok p1, TipPok p2)-> decltype (*p1+*p2) {
  10.     decltype (*p1+*p2) suma=0;
  11.     while (p1!=p2)  {
  12.             suma+=*p1;
  13.          p1++;
  14.     }
  15.     return suma;
  16. }
  17.  
  18. int main () {
  19.     vector<int> vek{2,3,4,2,2};
  20.     cout<<SumaBloka(vek.begin(), vek.end());
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement