记录一下冒泡排序
int temp;
int[] num = { 20, 5, 8, 110, 79, 65, 23 };
for (int i = 0; i < num.Length - 1; i++)
{
for (int j = 0; j < num.Length - 1 - i; j++)
{
if (num[j] > num[j + 1])
{
temp = num[j];
num[j] = num[j + 1];
num[j + 1] = temp;
}
}
}
for (int result = 0; result < num.Length; result++)
{
Console.WriteLine(num[result]);
}
int[] num = { 20, 5, 8, 110, 79, 65, 23 };
for (int i = 0; i < num.Length - 1; i++)
{
for (int j = 0; j < num.Length - 1 - i; j++)
{
if (num[j] > num[j + 1])
{
temp = num[j];
num[j] = num[j + 1];
num[j + 1] = temp;
}
}
}
for (int result = 0; result < num.Length; result++)
{
Console.WriteLine(num[result]);
}
效果如下