iOS crazy detailed sort (select Sort/insert sort)

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size:24px">Select sort</span></p></p><p><p><span style="font-size:18px">1. Minimum value first<br></span></p></p><p><p><span style="font-size:18px">2. Locate the location<br></span></p></p><p><p><span style="font-size:18px">3. Place the number of positions in the ordered area<br></span></p></p><p><p><span style="font-size:18px">4. Repeat<br></span><br></p></p><pre name="code" class="cpp"><pre name="code" class="cpp"> for (int j = 0; J < count-1; j + +) { int minindex = j;// The minimum value of the corner label for (int i = minindex + 1; i < count; i + +) { If (array[minindex] > array[i]) { minindex = i; } } If (minindex! = j) { // Optimize unordered area header is not first // minimum value put in head int temp; temp = array[minindex]; array[minindex] = array[j]; array[j] = temp; } }</pre></pre><br>Insert Sort<p><p></p></p><p><p></p></p><pre name="code" class="cpp"><pre name="code" class="cpp">for (int i = 1; i < count; i++) { Int j = i;// Determine the position of the current pit int temp = array[j]; target dequeue while (j > 0 && Temp < array[j-1]) { array[j] = array[j-1];//back top large j--; forward pit } array[j] = temp; target into the pit }</pre></pre><br><br><p><p></p></p><p><p>iOS crazy detailed sort (select Sort/insert sort)</p></p></span>

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.