旋转数组 1 2 3 4 5 5 1 2 3 4 4 5 1 2 3
t = a[n - 1]; for(i = 2; i < n; i++){ a[i] = a[i + 1]; } a[0] = t;
翻转的函数是reverse(a, a + k)
# include <algorithm> reverse(a, a + n); reverse(a, a + k); reverse(a + k, a + n);