mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
11 lines
253 B
C
11 lines
253 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;
|
||
|
}
|
||
|
}
|