#include <iostream>
using namespace std;
int main()
{
int arr[5] = { 1,2,3,4,5 };
int start = 0; //起始下标
int end = sizeof(arr) / sizeof(arr[0]) - 1;//结束下标
while (start < end)
{
int temp = arr[start];//中间变量
arr[start] = arr[end];
arr[end] = temp;
start++;
end--;
}
for (int i = 0; i < 5; i++)
{
cout << "arr = " << arr[i] << endl;
}
system("pause");
return 0;
}
C++逆序打印数组
最新推荐文章于 2025-05-25 20:11:13 发布