3 Select Sort

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.