3 solutions

  • -1
    @ 2025-5-11 10:50:11
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n,a[505],b[505];
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>> b[i];
            
        }
        for(int i=1;i<=n-1;i++){
            int t=b[i+1];
            int j=i;
            while(j>=1 && a[j]>t){
                b[j+1]=b[j];
                j--;
            }
            b[j+1]=t;
        }
        for(int i=1;i<=n;i++){
            cout<<b[i]<<",";
        }
    }
    

Information

ID
941
Time
1000ms
Memory
256MiB
Difficulty
3
Tags
(None)
# Submissions
68
Accepted
26
Uploaded By