Console.Write("输入数组长度为:");
int Length = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
int[] ary = new int[Length];
for (int i = 0; i < ary.Length; i++)
{
Console.Write("请输入第" + (i + 1) + "个数字:");
ary[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
}
for (int j = 0; j < ary.Length; j++)
{
for (int a = 1; a < ary.Length; a++)
{
if (ary[a - 1] > ary[a])
{
int temp = ary[a];
ary[a] = ary[a - 1];
ary[a - 1] = temp;
}
}
}
for (int a = 0; a < ary.Length; a++)
{
Console.Write(+ary[a] + " ");
}
Console.WriteLine("");
Console.ReadLine();
打开App,阅读手记