static void Main(string[] args)
{
int[] arr = {5,6,-2,3,9,7,1,-6 };
Px(arr);
}
public static void Px(int[] arr)
{
for (int i = 0; i < arr.Length-1; i++)
{
for (int j = 0; j < arr.Length-i-1; j++)
{
if (arr[j]>arr[j+1])
{
int arrs = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = arrs;
}
}
}
for (int i = 0; i < arr.Length; i++)
{
Console.Write(arr[i]+"\t");
}
Console.ReadKey();
}
输出: -6 -2 1 3 5 6 7 9
原文:http://www.cnblogs.com/sky-wolf/p/7694602.html