void swap(int *a, int *b) {
int t = *a;
*a = *b;
*b = t;
}
void reverse(int *nums, int start, int end) {
while (start < end) {
swap(&nums[start], &nums[end]);
start++;
end--;
}
}
yo peace!
void swap(int *a, int *b) {
int t = *a;
*a = *b;
*b = t;
}
void reverse(int *nums, int start, int end) {
while (start < end) {
swap(&nums[start], &nums[end]);
start++;
end--;
}
}
yo peace!
本文标题:【tip】翻转数组方法
本文链接:https://www.haomeiwen.com/subject/timkodtx.html
网友评论