1 /*2 Select Sort3 improved on the basis of bubbling sort4 find the smallest inside the unsorted5 6 7 Choose the difference between sort and bubble sort, select sort only once at a time, bubble sort may be exchanged multiple times8 Therefore, choosing a sort is more efficient than bubbling sorting9 Ten */ One A#include"Select.h" -#include <iostream> - the using namespacestd; - voidSelectsort (int*a,Const intn); - - + intMain () - { + Const intNlen =Ten; A intx[nlen]={1,3,5,7,9,2,4,6,8,Ten}; at - Selectsort (X,nlen); - - for(intI=0; i<nlen;i++) - { -cout<<x[i]<<" "; in } - to +cout<<Endl; -System"Pause"); the return 0; * } $ Panax Notoginseng - voidSelectsort (int*list,Const intN) the { + A for(intI=0; i<n;i++) the { + - intNminflag = i;//Towel, subscript $ $ for(intj=i+1; j<n;j++)//every time you scan, start from where you've been scanned. - { - if(List[j] <List[nminflag]) the { -Nminflag = j;//remember the subscript .Wuyi } the - } Wu - swap (List[i],list[nminflag]); About } $ - return; -}
3 Select Sort