Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <stdexcept>
- #include <list>
- using namespace std;
- template < typename TipPok1, typename TipPok2>
- TipPok2 KumulativnaSuma (TipPok1 It1, TipPok1 It2, TipPok2 It3) {
- int brojac{1};
- for (auto p(It1); p!=It2; p++, brojac++) {
- auto q(It1);
- for (int i=0; i<brojac; i++)
- *It3+=*q++;
- It3++;
- }
- return It3;
- }
- int main () {
- list<int> l{1,2,3,4,5,6,7,8};
- vector<int> vek(l.size());
- KumulativnaSuma(l.begin(), l.end(), vek.begin());
- for (auto x: vek) cout<<x<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement