fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int N=1e6+4;
  4. long long a[N],n;
  5. int main()
  6. {
  7. cin>>n;
  8. for(int i=0;i<n;i++) cin>>a[i];
  9. for(int i=1;i<=n-1;i++)
  10. {
  11. long long x=a[i],pos=i-1;
  12. while(pos>=0 && a[pos]>x)
  13. {
  14. a[pos+1]=a[pos];
  15. pos--;
  16. }
  17. a[pos+1]=x;
  18. cout<<"Buoc "<<i<<": ";
  19. for(int j=0;j<n;j++) cout<<a[j]<<" ";
  20. cout<<endl;
  21. }
  22. }
  23.  
Success #stdin #stdout 0.01s 5432KB
stdin
Standard input is empty
stdout
Standard output is empty