mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
14 lines
303 B
C
14 lines
303 B
C
void rotate(int *nums, int numsSize, int k)
|
|
{
|
|
for (int i = 1; i <= k; i++)
|
|
{
|
|
int j;
|
|
int lastElement;
|
|
lastElement = nums[numsSize - 1];
|
|
for (j = numsSize - 1; j > 0; j--)
|
|
{
|
|
nums[j] = nums[j - 1];
|
|
}
|
|
nums[0] = lastElement;
|
|
}
|
|
} |