标签:style blog class c code java
http://zhedahht.blog.163.com/blog/static/2541117420073993725873/
左旋转字符串:
k=2
AB1234 =>1234AB
思路:
AB=>BA
1234=>4321
BA4321=>1234AB
char * LeftRotateString(char *pStr,int k) { if (pStr!=NULL) { int n = strlen(pStr); if (k>0&&n>0&&k<n) { // reverse first part Reverse(pStr,pStr+k-1); // reverse second part Reverse(pStr+k,pStr+n-1); // reverse whole part Reverse(pStr,pStr+n-1); } } return pStr; }
标签:style blog class c code java
原文地址:http://www.cnblogs.com/hellogiser/p/3738770.html