Preview:
}


#include <iostream>

using namespace std;

int main()
{
    int N ; 
    int X[N] ; 
    cin>>N ; 
    for(int i=0 ;i<N ;i++ ) { 
        cin>>X[i] ; 
    } 
    
    for(int i=0;i<N-1 ;i++ ){ 
        int M=X[i] ; //M=3
        int ind ; 
        for(int J=i+1 ;J<N ;J++){  // 0 1 2 3 4 
                                   // 1 3 2

            if(X[J]<M){
                M=X[J] ; 
                ind=J ;           //1 
                
            } 
            
         
    }  
    int temp =X[i] ; 
    X[i]=M ; 
    X[ind]=temp ;
    } 
    for(int i=0 ;i<N ;i++){
        cout<<X[i]<<" ";
    }
    
    

    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter