Last active
September 13, 2018 01:45
-
-
Save LucianoPAlmeida/63ccab7ec255ae8dbb17859c7331fe15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <array> | |
#include <vector> | |
int main(int argc, const char * argv[]) { | |
std::vector<int> numbers = {0, 2, 1, 4, 5, -2, 4}; | |
std::stable_sort(numbers.begin(), numbers.end(), std::greater<int>()); | |
std::cout << "Descending: " << std::flush; | |
for(auto i: numbers) { | |
std::cout << i << " " << std::flush; | |
} | |
std::stable_sort(numbers.begin(), numbers.end()); | |
std::cout << std::endl; | |
std::cout << "Ascending: " << std::flush; | |
for(auto i: numbers) { | |
std::cout << i << " " << std::flush; | |
} | |
std::cout << std::endl; | |
return 0; | |
} | |
// Output | |
// Descending: 5 4 4 2 1 0 -2 | |
// Ascending: -2 0 1 2 4 4 5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment