1.将一个具有5个元素的数组中的数据逆序,并输出原始数组中的数据及逆序后数组中的数据。 有人会编吗?
//5个数据
string[] arr = new string[] { "1", "2", "3", "4", "5" }; //可以任何类型
for (int i = arr.Length-1; i >= 0; i--)
{
Console.Write(arr[i] + "\t"); //数据逆序
}
Console.WriteLine();
for (int i = 0; i < arr.Length; i++)
{
Console.Write(arr[i] + "\t"); //原始数组
}