冒泡排序

来源:互联网 发布:wap论坛源码 编辑:程序博客网 时间:2024/05/01 17:12
namespace ConsoleApplication6{    class SortHelper<T> where T : IComparable    {        public void BuubleSort(T[] arr)        {            int length = arr.Length;            for (int i = 0; i < length - 1; i++)            {                for (int j = 0; j < length - 1; j++)                {                    if (arr[j].CompareTo(arr[j + 1]) > 0)                    {                        T temp = arr[j];                        arr[j] = arr[j + 1];                        arr[j + 1] = temp;                    }                }            }        }    }}

0 0
原创粉丝点击