Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- template<typename T1, typename T2>
- T2 KumulativnaSuma (T1 p1, T1 p2, T2 p3)
- {
- auto prethodni = 0;
- while (p1 != p2)
- {
- *p3 = prethodni + *p1;
- prethodni=*p3;
- p1++;
- p3++;
- }
- return p3;
- }
- int main()
- {
- std::vector<int> v= {1,20,50,8,9,11,2};
- std::vector<int> v1(7);
- auto p =KumulativnaSuma(v.begin(), v.end(),v1.begin());
- for(int i=0; i<v1.size(); i++)
- std::cout << v1[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment