#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
void inverte(int* p, int n)
{
int* s, * i, * j;
int temp, m = (n - 1) / 2;
i = p;
j = p + n - 1;
s = p + m;
/*将数组前半部分和后半部分元素交换位置*/
for (; i <= s; i++, j--)
{
temp = *i;
*i = *j;
*j = temp;
}
}
int main()
{
/*用指针实现逆序存放数组元素值*/
int i;
int a[] = { 1, 2, 3, 4, 5, 6};
int sz = sizeof(a) / sizeof(a[0]);
inverte(a, sz);
for (i = 0; i < sz; i++)
{
printf("a[%d] = %d\n", i, a[i]);
}
return 0;
}