SHARE
TWEET

Untitled

a guest Jul 18th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a[1000],n;
  8.     cin>>n;
  9.     for(int i=0;i<n;i++){
  10.         cin>>a[i];
  11.     }
  12.     for(int i=0;i<n-1;i++){
  13.         int min1=a[i],posMin=i;
  14.         for(int j=0;j<n;j++){
  15.             if(a[j]<min1){
  16.                 min1=a[j];
  17.                 posMin=j;
  18.             }
  19.         }
  20.         swap(a[i],a[posMin]);
  21.     }
  22.     for(int i=0;i<n;i++){
  23.         cout<<a[i]<<" ";
  24.     }
  25.     return 0;
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top