static void Main(string[] args)
{
M k = new HanShu.Program.M();
k.b3(k.b2(k.b()));
Console.ReadKey();
}
public class M
{
public int [] b()
{
Console.WriteLine("请输入一个数来定义数组长度");
int z = Convert.ToInt32(Console.ReadLine());
int[] x = new int[z];
Console.WriteLine("请输入"+x .Length +"个元素");
for (int i = 0; i < x.Length ; i++)
{
x[i] = Convert.ToInt32(Console.ReadLine());
}
return x;
}
public int [] b2(int []x2)
{
for (int i = 0; i < x2 .Length -1; i++)
{
for (int j = 0; j < x2 .Length -1-i ; j++)
{
if (x2 [j ]>x2 [j +1])
{
int b = x2[j + 1];
x2[j + 1] = x2[j];
x2[j] = x2[j + 1];
}
}
}
return x2;
}
public void b3(int [] b3)
{
Console.WriteLine("输出元素");
foreach (var item in b3 )
{
Console.WriteLine(item );
}
}
}
}
}