zoukankan      html  css  js  c++  java
  • 【数据结构】——插入排序

    插入排序:

     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 #include<string.h>
     4 
     5 int arry[7] = {49,38,65,97,76,13,27};
     6 
     7 void show_arry()
     8 {
     9     int i;
    10     for(i = 0; i < 7; i++)
    11         printf("%d ",arry[i]);
    12     putchar('
    ');
    13 }
    14 
    15 void sort()
    16 {
    17     int i,j;
    18     int tmp;
    19     for(i = 0; i < 7; i++){
    20         j = i;
    21         tmp = arry[i];
    22         while(j > 0 && tmp < arry[j - 1]){
    23             arry[j] = arry[j - 1];
    24             arry[j - 1] = tmp;
    25             j--;     
    26         }
    27     }    
    28 }
    29 
    30 void text()
    31 {
    32     arry[0] = 0;
    33     arry[1] = 1;
    34 }
    35 
    36 int main(int argc, char *argv[])
    37 {
    38     puts("before sort");
    39     show_arry();
    40     sort();
    41     //text();
    42     puts("after sort");
    43     show_arry();
    44     return 0;
    45 }
  • 相关阅读:
    10.7
    10.5
    周六
    周五
    周四
    周三
    四则运算
    zabbix——yum安装
    Stirling's Formula
    CONTRASTIVE REPRESENTATION DISTILLATION
  • 原文地址:https://www.cnblogs.com/ngnetboy/p/3397345.html
Copyright © 2011-2022 走看看