IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    插入排序

    snowhill发表于 2006-12-27 14:20:00
    love 0
     1 #include "iostream.h"
     2 
     3 void insertsort(int a[],int m)
     4 {
     5         int temp,j;
     6         
     7         for(j=1;j<m;j++)
     8         {
     9             
    10             if(a[j-1]>a[j])
    11             {
    12                 temp=a[j];
    13                     for(int i=j-1;a[i]>=temp&&i>=0;i--)
    14                     {
    15                     a[i+1]=a[i];
    16                     }
    17                 a[i+1]=temp;
    18             }
    19         }
    20         
    21     
    22 }


    snowhill 2006-12-27 22:20 发表评论


沪ICP备19023445号-2号
友情链接