int[] a = new int[5] {4,3,5,1,2};
int temp = 0;
int i,j;
for (j = 0; j< a.Length; j++)
for (i = 0; i < a.Length - j - 1; i++)//这里的a.Lengeth-j-1为什么还要在-1??
{
if (a[i] > a[i+1])
{
temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
}
}
for (int m = 0; m < a.Length; m++)
{
Console.WriteLine(a[m]);
a.Lengeth-j-1为什么还要在-1??
|