70,022
社区成员




for(int i=0; i<k; i++)
{
tp1 = *(p+len-1);
--p;
while(*++p != '\0')
{
tp2 = *p;
*p = tp1;
tp1 = tp2;
}
//让p重新指向字符串首字母
p = p-len;
printf("the current name is:%s\n",p);
}
while(*p != '\0')
{
tp2 = *p;
*p = tp1;
tp1 = tp2;
++p;
}
char *LoopRMove(char *str,int k);
void main(int argc,char *argv)
{
char name[] = "abcde";
char *p = name;
p = LoopRMove(p,29);
//printf("the current name is:%s\n",p);
return;
}
char *LoopRMove(char *str,int k)
{
char *p = str;
int len = 0;
while(*p != '\0')
{
len++;
p++;
}
p = p-len;
if(k%len == 0) return str;
k = k%len;
char tp1;
for(int i=0; i<k; i++)
{
tp1 = *(p+len-1);
for (int j=len-1;j>0;j--)
{
p[j]=p[j-1];
}
p[0]=tp1;
// while(*p++ != '\0')
// {
// tp2 = *p;
// *p = tp1;
// tp1 = tp2;
// }
// //让p重新指向字符串首字母
// p = p-len;
printf("the current name is:%s\n",p);
}
return str;
}