算法--冒泡排序

来源:互联网 发布:网站源码小偷程序 编辑:程序博客网 时间:2024/06/05 19:30
public class BubbleSort{    public void sort(int[] a)    {        int temp = 0;        for (int i = a.length - 1; i > 0; --i)        {            for (int j = 0; j < i; ++j)            {                if (a[j + 1] < a[j])                {                    temp = a[j];                    a[j] = a[j + 1];                    a[j + 1] = temp;                }            }        }    }}
0 0
原创粉丝点击