using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
int[] seq = new int[10];
for (int i = 0; i < 10; i++)
{
seq[i] = i + 1;
}
int temp;
int len = seq.Length;
for (int i = 0; i < len; i++)
{
Console.WriteLine(seq[i]);
}
for (int i = 0; i <= len / 2; i++)
{
temp=seq[i];
seq[i] = seq[len-i-1];
seq[len - i-1] = temp;
}
for (int i = 0; i < len; i++)
{
Console.WriteLine(seq[i]);
}
}
}
}
注意i的取值范围是0到n/2,实现倒置时应取len-i-1,有的书上是取len-i是错误的