init commit

This commit is contained in:
2024-03-19 01:05:51 +08:00
commit 199bbf2628
393 changed files with 34883 additions and 0 deletions

View File

@ -0,0 +1,28 @@
#include <stdio.h>
/**
* https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/1/array/23/
* 旋转数组
*/
void rotate(int *nums, int numsSize, int k)
{
int end = 0;
for (int i = 0; i < k; i++)
{
//记录最后一位,数组向后移动一位
end = nums[numsSize - 1];
for (int n = 0; n < numsSize; n++)
{
nums[numsSize - n - 1] = nums[numsSize - n - 2];
}
nums[0]=end;
}
}
int main()
{
int nums[] = {1, 2, 3, 4, 5, 6, 7};
rotate(nums, 7, 3);
return 0;
}