fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, v[11], w[11];
  6. cin >> n;
  7. for (int i = 1; i <= n; ++i) {
  8. cin >> v[i];
  9. }
  10. for (int i = 1; i <= n; ++i) {
  11. cin >> w[i];
  12. }
  13. int m = n;
  14. bool sorted;
  15. do {
  16. sorted = true;
  17. for (int i = 1; i < m; i++)
  18. if (w[i] < w[i + 1]) {
  19. int aux = w[i];
  20. w[i] = w[i + 1];
  21. w[i + 1] = aux;
  22. sorted = false;
  23. }
  24. m--;
  25. } while (!sorted);
  26. for (int i = 1; i <= n; ++i) {
  27. cout << w[i] << " ";
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0s 5272KB
stdin
7
7 6 5 4 3 2 1
5 4 2 3 7 1 6 
stdout
7 6 5 4 3 2 1