void inplace_swap(int *x, int *y)
{
*y ^= *x;
*x ^= *y;
*y ^= *x;
}
void reverse_array(int a[], int cnt)
{
int first, last;
for (first = 0, last = cnt - 1; first < last; ++first, --last)
{
inplace_swap(&a[first], &a[last]);
}
}
将数组中的元素头尾两端依次对调
最新推荐文章于 2023-01-31 23:24:22 发布