c#冒泡排序
int[] a = { 1, 8, 3, 6, 9, 4 };
for (int i = 0; i < a.Length-1; i++)
{
for (int j = 0; j < a.Length-i-1; j++)
{
if (a[j]>a[j+1])
{
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine(a[i]);
}
Console.ReadKey();
浙公网安备 33010602011771号