數組的排序(從小到大),逆向排序

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{數組

int[] Arrays = new int[] { 24, 14, 35, 86, 55, 68, 15 };//建立一個數組名爲Arrays的數組
Console.WriteLine("從小到大排序的數組");
for (int i = 0; i < Arrays.Length;i++ ) {//遍歷Arrays數組
}
Array.Sort(Arrays);//使用Sort方法排序
for (int i = 0; i < Arrays.Length;i++ ) {
Console.Write(Arrays[i]+" ");//輸出數組
}
Console.ReadLine();
spa

 

Console.WriteLine();//分割線
排序

 

Console.WriteLine("逆向排序後的數組")string

for (int i = 0; i < Arrays.Length;i++ ) {//遍歷Arrays數組it

}
Array.Reverse(Arrays);//使用Reverse方法逆向排序數組
for (int i = 0; i < Arrays.Length;i++ ) {
Console.Write(+Arrays[i] + " ");
}
Console.ReadLine();
}
}
}
io

相關文章
相關標籤/搜索