#include <iostream> using namespace std; void select_sort(int array[],int n){ int i,j,k,t; for(i=0;i<n-1;i++){ k=i; for(j=i+1;j<n;j++){ if(array[j]<array[k]){ k=j; } t=array[k]; array[k]=array[i]; array[i]=t; } } } int main(){ int a[10]={84,4,24,26,63,69,37,54,87,36}; select_sort(a,10); for(int i=0;i<10;i++){ cout<<a[i]<<" "; } cout<<endl; }
时间: 2024-11-08 01:05:37