#include<stdio.h>
#include<string.h>
void swap(char *l,char *r)
{
while(l<r)
{
char tmp=*l;
*l=*r;
*r=tmp;
l++;
r--;
}
}
void RightLoopMove(char *pStr,unsigned short steps)
{
int len=strlen(pStr);
swap(&pStr[0],&pStr[len-1-steps]);
swap(&pStr[len-steps],&pStr[len-1]);
swap(&pStr[0],&pStr[len-1]);
}
int main()
{
char str[]="abcdefghi";
RightLoopMove(str,3);
printf("%s\n",str);
return 0;
}
字符串右循环移位
最新推荐文章于 2021-09-13 11:51:14 发布