槿栀ZJ
2018-03-08 17:37:59浏览 1870
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();