Hope someone help me .I don't know why the input "[1], 0" is corecct and what's wrong with my code.

```
class Solution {
public:
void rotate(int nums[], int n, int k) {
int temp1,temp2;
int i,j;
if(n<=0)
return;
if(k>n)
k=k%7;
temp2=nums[0];
for(i=0;i<n-k;i++)
{
j=i;
do
{
temp1=temp2;
temp2=nums[j+k];
nums[j+k]=temp1;
j=j+k;
}
while(j<n);
}
return;
}
};
```