#include<stdio.h> #include<string.h> void RightLoopMove(char *pStr, unsigned short steps) { int i = 0; int len = strlen(pStr); char a; while (steps) { a = pStr[len -1]; for (i = len - 1; i > 0; i--) { pStr[i] = pStr[i - 1]; } pStr[0] = a; steps--; } } int main() { char str[] ="abcdefghi"; RightLoopMove(str, 2); printf("%s\n", str); getchar(); return 0; }
时间: 2024-11-19 20:45:02