fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm> // for sort
  4.  
  5. int main()
  6. {
  7. int x[10] = { 1,3,5,7,9,2,4,6,8,10 };
  8. std::vector<int> vec(x, x+10); // construct std::vector object
  9. std::sort(vec.rbegin(),vec.rend()); // sort it in reverse manner
  10. for(int i = 0; i < 10; ++i)
  11. std::cout << vec[i] << " ";
  12. }
  13.  
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
10 9 8 7 6 5 4 3 2 1