Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <iterator>
- int myrand()
- {
- return rand()%100;
- }
- template <typename T>
- void myprint(std::vector<T> arg)
- {
- std::copy(arg.begin(), arg.end(), std::ostream_iterator<T>(std::cout," ")); std::cout << std::endl;
- }
- int main()
- {
- std::vector<int> a(10);
- std::generate(a.begin(), a.end(), myrand);
- myprint(a); std::sort(a.begin(), a.end());
- myprint(a);
- std::random_shuffle(a.begin(), a.begin()+5); myprint(a); std::partial_sort(a.begin(),a.begin()+5, a.end()); myprint(a); return 0;
- }
Add Comment
Please, Sign In to add comment