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. for (int i = 0; i < n; ++i) {
  10. int j = i;
  11. while (j > 0 && a[j] < a[j - 1]) {
  12. swap(a[j], a[j - 1]);
  13. j--;
  14. }
  15.  
  16. cout << "Buoc " + to_string(i) + ": ";
  17. for (int j = 0; j <= i; ++j) {
  18. cout << a[j] << " ";
  19. }
  20. cout << endl;
  21. }
  22. }
  23.  
  24. int main() {
  25. ios_base::sync_with_stdio(false);
  26. cin.tie(NULL); cout.tie(NULL);
  27.  
  28. int T = 1;
  29. while (T--) {
  30. testCase();
  31. cout << "\n";
  32. }
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout