实现:元素逆置

#include<iostream>
#include<string>

using namespace std;

int main() 
{
	int arr[6] = {1,2,3,4,5,6};
	int i = 0;
	int j = sizeof(arr) / sizeof(int) - 1;
	
	while (i < j) {
		int temp = arr[i];
		arr[i] = arr[j];
		arr[j] = temp;
		i++;
		j--;
	}

	for (i = 0; i < 6; i++) {
		cout << arr[i] << endl;

	}
	system("pause");
	return 0;
}
原文地址:https://www.cnblogs.com/zpchcbd/p/11839756.html