<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # C 中的插入排序程序 > 原文: [https://beginnersbook.com/2015/02/insertion-sort-program-in-c/](https://beginnersbook.com/2015/02/insertion-sort-program-in-c/) 插入排序算法逐個選擇元素,并將其放置在元素有序列表中的所在位置。在下面的 C 程序中,我們實現了相同的邏輯。 在完成程序之前,讓我們看一下示例幫助下的插入排序步驟。 + 輸入元素:89 17 8 12 0 + 步驟 1: **89** 17 8 12 0(粗體元素是有序列表,非粗體是無序列表) + 步驟 2: **17 89** 8 12 0(每個元素將從無序列表中刪除并放置在有序列表中的正確位置) + 步驟 3: **8 17 89** 12 0 + 步驟 4: **8 12 17 89** 0 + 步驟 5: **0 8 12 17 89** #### C 程序 - 插入排序實現 ```c #include<stdio.h> int main(){ /* Here i & j for loop counters, temp for swapping, * count for total number of elements, number[] to * store the input numbers in array. You can increase * or decrease the size of number array as per requirement */ int i, j, count, temp, number[25]; printf("How many numbers u are going to enter?: "); scanf("%d",&count); printf("Enter %d elements: ", count); // This loop would store the input numbers in array for(i=0;i<count;i++) scanf("%d",&number[i]); // Implementation of insertion sort algorithm for(i=1;i<count;i++){ temp=number[i]; j=i-1; while((temp<number[j])&&(j>=0)){ number[j+1]=number[j]; j=j-1; } number[j+1]=temp; } printf("Order of Sorted elements: "); for(i=0;i<count;i++) printf(" %d",number[i]); return 0; } ``` **輸出:** ![insertion_sort_output_cmd](https://img.kancloud.cn/86/ca/86ca86f43500870731e1e0e9e1a12d61_541x236.jpg) 正如您可以在輸出中觀察到的那樣,我們以隨機順序輸入了 6 個整數,并且上面的 C 程序通過使用插入排序算法的邏輯以升序對它們進行排序。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看