问:将字符串的n个字符左旋
例 :asdf左旋一个sdfa
asdf左旋两个dfas
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include<string.h> void Ayue(char* ar, int k) { int i = 0; int sz = strlen(ar); for (i = 0; i < k; i++) { char tmp = *ar; int j = 0; for (j = 0; j < sz-1; j++) { *(ar + j) = *(ar + j + 1); } *(ar + sz - 1) = tmp; } } int main() { char ar[] = "abcdef"; Ayue(ar, 2); printf("%s\n",ar); return 0; }
标签:sz,int,代码,练习,34,char,ar,左旋,asdf From: https://www.cnblogs.com/ayue6/p/17784863.html