Guest User

Untitled

a guest
Sep 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <iterator>
  5. int myrand()
  6. {
  7. return rand()%100;
  8. }
  9. template <typename T>
  10. void myprint(std::vector<T> arg)
  11. {
  12. std::copy(arg.begin(), arg.end(), std::ostream_iterator<T>(std::cout," ")); std::cout << std::endl;
  13.  
  14. }
  15.  
  16. int main()
  17. {
  18. std::vector<int> a(10);
  19. std::generate(a.begin(), a.end(), myrand);
  20. myprint(a); std::sort(a.begin(), a.end());
  21. myprint(a);
  22. std::random_shuffle(a.begin(), a.begin()+5); myprint(a); std::partial_sort(a.begin(),a.begin()+5, a.end()); myprint(a); return 0;
  23. }
Add Comment
Please, Sign In to add comment