标签:bsp 左旋转 alt ima idt span turn 旋转 rds
题目:
解答:
1 class Solution { 2 public: 3 string reverseLeftWords(string s, int n) 4 { 5 reversestr(s, 0, n); 6 reversestr(s, n, s.size()); 7 reversestr(s, 0, s.size()); 8 return s; 9 10 } 11 void reversestr(string &s, int begin, int end) 12 { 13 int i = begin, j = end - 1; 14 char tmp; 15 while(i < j) 16 { 17 tmp = s[i]; 18 s[i] = s[j]; 19 s[j] = tmp; 20 ++i; 21 --j; 22 } 23 } 24 };
标签:bsp 左旋转 alt ima idt span turn 旋转 rds
原文地址:https://www.cnblogs.com/ocpc/p/12859796.html