Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <array>
- #include <random>
- using uint = unsigned int;
- int main()
- {
- std::array<uint, 30> tab;
- for (auto i = 0u; i < 30; ++i) {
- tab[i] = i+10;
- }
- // na czysto
- std::copy(tab.begin(), tab.end(), std::ostream_iterator<uint>(std::cout, " "));
- std::cout << std::endl;
- std::mt19937 g(std::random_device{}());
- std::shuffle(tab.begin(), tab.end(), g);
- // losowo
- std::copy(tab.begin(), tab.end(), std::ostream_iterator<uint>(std::cout, " "));
- std::cout << std::endl;
- std::partial_sort(tab.begin(), tab.begin()+10, tab.end(), [](uint a, uint b){return a>b;});
- // częściowo posortowane
- std::copy(tab.begin(), tab.end(), std::ostream_iterator<uint>(std::cout, " "));
- std::cout << std::endl;
- char x;
- std::cin >> x;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement