fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void testCase() {
  5. int n; cin >> n;
  6. vector<int> a(n);
  7. for (int &i : a) cin >> i;
  8.  
  9. // Selection sort
  10. for (int i = 0; i < n - 1; ++i) {
  11. int index = i;
  12. for (int j = i + 1; j < n; ++j) {
  13. if (a[j] < a[index])
  14. index = j;
  15. }
  16. swap(a[i], a[index]);
  17.  
  18. cout << "Buoc " + to_string(i + 1) + ": ";
  19. for (int j = 0; j < n; ++j) {
  20. cout << a[j] << " ";
  21. }
  22. cout << endl;
  23. }
  24. }
  25.  
  26. int main() {
  27. ios_base::sync_with_stdio(false);
  28. cin.tie(NULL); cout.tie(NULL);
  29.  
  30. int T = 1;
  31. while (T--) {
  32. testCase();
  33. cout << "\n";
  34. }
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout