选择排序
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; void Choicesort(int *a){ for(int i=1;i<=5;i++){ for(int j=i+1;j<=5;j++){ if(a[i]>a[j]) swap(a[i],a[j]); } } return ; } int main(){ int a[6]={0,4,5,1,3,7}; Choicesort(a); for(int i=1;i<=5;i++) cout<<a[i]<<" "; return 0; }