int[] arr = new int[5];
int first = 0, last = arr.Length - 1, temp;
//遍历数组并从键盘输入五个元素
for (int i=0;i<arr.Length;i++)
{
Console.WriteLine("请输入第{0}个整数:",i+1);
arr[i] = Convert.ToInt32(Console.ReadLine());
}
//逆序存放数组中的数据
while (first < last)
{
temp = arr[first];
arr[first] = arr[last];
arr[last] = temp;
first++;
last--;
}
//输出逆序存放后的数组元素
Console.Write("最终结果为:");
for (int y = 0; y < arr.Length; y++)
{
Console.Write(" " + arr[y]);
}
Console.ReadKey();
运行结果: