首页 > 编程语言 > 详细

冒泡算法

时间:2014-12-08 19:15:48      阅读:187      评论:0      收藏:0      [点我收藏+]

void swap(int *x, int *y)
{
     int temp;
  temp=*x;
  *x=*y;
  *y=temp; 
}

void mpao(int* a,int n)
{
 int x,y;
    for(x=1;x<n-1;x++)
 {
  for(y=x-1;y>=0&&a[y]>a[x];y--,x--)
  {
   swap(&a[y],&a[x]);
  }
 } 
}

冒泡算法

原文:http://www.cnblogs.com/roads-untralla/p/4151668.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!