轮转数组
void rotate(int* nums, int numsSize, int k)
{
if (k > numsSize)
{
k %= numsSize;
}
int* tmp = (int*)malloc(sizeof(int) * numsSize);
//copy后k个
memcpy(tmp, nums + numsSize - k, sizeof(int) * k);
memcpy(tmp + k, nums, sizeof(int) * (numsSize-k));
memcpy(nums, tmp, sizeof(int) * (numsSize));
free(tmp);
}
方法: