标签:排序算法 static 算法 冒泡排序 排序 i++ enum ber console
/*
* 冒泡排序算法
*/
int[] numbers = { 23, 24, 44, 21, 94, 12, 26, 09 };
for (int i = 0; i < numbers.Length; i++)
{
for (int j = i + 1; j < numbers.Length; j++)
{
if (numbers[j] < numbers[i])
{
ChangeNumber(numbers[j], numbers[i]);
}
}
}
for (int i = 0; i < numbers.Length; i++)
{
Console.WriteLine(numbers[i]);
}
Console.ReadKey();
}
/*
* 变量互换
*/
static void ChangeNumber(int number1, int number2)
{
number1 = number1 + number2;
number2 = number1 - number2;
number1 = number1 - number2;
}
标签:排序算法 static 算法 冒泡排序 排序 i++ enum ber console
原文地址:http://www.cnblogs.com/furuipeng/p/7281279.html