Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a[1000],n;
- cin>>n;
- for(int i=0;i<n;i++){
- cin>>a[i];
- }
- for(int i=0;i<n-1;i++){
- int min1=a[i],posMin=i;
- for(int j=0;j<n;j++){
- if(a[j]<min1){
- min1=a[j];
- posMin=j;
- }
- }
- swap(a[i],a[posMin]);
- }
- for(int i=0;i<n;i++){
- cout<<a[i]<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement