新代码

时间:2015-07-12 12:33:00   收藏:0   阅读:109

?

?

技术分享

?

?

public static void BubbleSort<T>(T[] arrayList) where T : IComparable<T>

{

for (int i = 0; i < arrayList.Length - 1; i++)

{

for (int j = 0; j < arrayList.Length - i - 1; j++)

{

if (arrayList[j].CompareTo(arrayList[j + 1]) > 0)

{

T temp = arrayList[j];

arrayList[j] = arrayList[j + 1];

arrayList[j + 1] = temp;

}

}

}

}

?

?

?

public static void BubbleSort<T>(T[] arrayList) where T : IComparable<T>

{

for (int i = 0; i < arrayList.Length - 1; i++)

{

for (int j = 0; j < arrayList.Length - i - 1; j++)

{

if (arrayList[j].CompareTo(arrayList[j + 1]) > 0)

{

T temp = arrayList[j];

arrayList[j] = arrayList[j + 1];

arrayList[j + 1] = temp;

}

}

}

}

?

?

?

?

?

?

?

?

?

?

?

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!