avukas

2013-2014: I parcijalni: 6zad

Apr 10th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3.  
  4. template<typename T1, typename T2>
  5.  
  6. T2 KumulativnaSuma (T1 p1, T1 p2, T2 p3)
  7. {
  8.     auto prethodni = 0;
  9.     while (p1 != p2)
  10.     {
  11.  
  12.         *p3 = prethodni + *p1;
  13.         prethodni=*p3;
  14.         p1++;
  15.         p3++;
  16.     }
  17.  
  18.     return p3;
  19. }
  20.  
  21. int main()
  22. {
  23.     std::vector<int> v= {1,20,50,8,9,11,2};
  24.     std::vector<int> v1(7);
  25.     auto p =KumulativnaSuma(v.begin(), v.end(),v1.begin());
  26.  
  27.     for(int i=0; i<v1.size(); i++)
  28.         std::cout << v1[i] << " ";
  29. }
Advertisement
Add Comment
Please, Sign In to add comment