fork download
  1. // sort algorithm example
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. bool compare(int a, int b) {
  8. return (a > b);
  9. }
  10.  
  11. int main () {
  12. int x[] = {2, 4, 1, 7, 8, 0, 9};
  13. sort(x, x + sizeof(x) / sizeof(int), compare);
  14. for (int y: x) cout << ' ' << y;
  15. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
 9 8 7 4 2 1 0