fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_VALUE = 1000;
  5.  
  6. int main() {
  7. int n, v[MAX_VALUE + 1];
  8. cin >> n;
  9. for (int i = 1; i <= n; ++i) {
  10. cin >> v[i];
  11. }
  12. int sortat = 0, aux;
  13. while (sortat == 0) {
  14. sortat = 1;
  15. for (int i = 1; i < n; ++i) {
  16. if (v[i] > v[i + 1]) {
  17. sortat = 0;
  18. aux = v[i];
  19. v[i] = v[i + 1];
  20. v[i + 1] = aux;
  21. }
  22. }
  23. }
  24. for (int i = 1; i <= n; ++i) {
  25. cout << v[i] << ' ';
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5264KB
stdin
Standard input is empty
stdout
Standard output is empty