//一個數組有8個元素,將前3個元素通過移動串到後3個位置上,如果其初始數據爲: 1 2 3 4 5 6 7 8
//不增加數組,也不增加數組的存儲單元,通過移動數組元素將數組變化爲: 4 5 6 7 8 1 2 3
using System;
namespace 反轉數組
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
Array.Reverse(a, 0, 8);
Array.Reverse(a, 0, 5);
Array.Reverse(a, 5, 3);
for (int i = 0; i < a.Length; i++)
{
Console.Write("{0} ", a[i]);
}
}
}
}