Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <deque>
- template<typename tip, typename TipS>
- auto SumaBloka(tip p1, tip p2, TipS suma) -> decltype(*p1 + *p2)
- {
- while (p1 != p2)
- {
- suma=suma+*p1;
- p1++;
- }
- return suma;
- }
- int main()
- {
- std::deque<int> d;
- int n;
- std::cout<<"Unesi dimenziju bloka:\n";
- std::cin>>n;
- std::cout<<"\nUnesi elemente bloka:\n";
- for (int i(0); i<n; i++)
- {
- int pom;
- std::cin>>pom;
- d.push_back(pom);
- }
- int suma(0);
- int s = SumaBloka(d.begin(), d.end(), suma);
- std::cout<<"\nSuma bloka je: "<<s<<std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment