Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <list>
- template<typename NekiTip>
- void SortirajListu(std::list<NekiTip> &lista)
- {
- typename std::list <int>::iterator it2;
- typename std::list<int>::iterator it;
- for ( auto it=lista.begin(); it!=lista.end(); it++)
- {
- for (auto it2 (it); it2!=lista.end(); it2++)
- {
- if (*it2<*it)
- {
- std::swap (*it2, *it);
- }
- }
- }
- }
- int main()
- {
- std::list<int> lista {1,6,5,9,7,2,4};
- SortirajListu(lista);
- for (int x:lista)
- std::cout<< x << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment