#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define Max 11
int main(){
int length;
cout<<"input the length:";
cin>>length;
int data[length+1];
cout<<"input the array:";
for(int i=1;i<=length;i++){
int a;
cin>>a;
data[i]=a;
}
for(int i=1;i<length;i++){
int min=data[i];
int p=1;
for(int j=i+1;j<=length;j++){
if(data[j]<min){
min=data[j];
p=j;
}
}
int temp=data[i];
data[i]=data[p];
data[p]=temp;
}
for(int i=1;i<=length;i++){
cout<<data[i]<<" ";
}
}
04-06
1960
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)