#include <iostream>
using namespace std;
void reverse_str(char* s, int l, int h)
{
while(l<h)
{
swap(s[l++], s[h--]);
}
}
void left_rotate_reverse(char* s, int k, int n)
{
reverse_str(s, 0, k-1);
reverse_str(s, k, n-1);
reverse_str(s, 0, n-1);
}
int main()
{
char s[] = "0123456789";
cout<<s<<endl;
left_rotate_reverse(s, 3, strlen(s));
cout<<s<<endl;
return 0;
}
字符串循环移位
最新推荐文章于 2013-10-16 20:43:51 发布