标签:字符串 height amp public color return star temp div
题目:
解答:
1 class Solution { 2 public: 3 int reverse_string(string& s, int start, int end) 4 { 5 for (int i = start; i <= (start + end) / 2; i++) 6 { 7 char temp = s[i]; 8 s[i] = s[start+end-i]; 9 s[start+end-i] = temp; 10 } 11 return 0; 12 } 13 14 string reverseLeftWords(string s, int n) 15 { 16 int length = s.length(); 17 18 reverse_string(s, 0, length-1); 19 reverse_string(s, 0, length-n-1); 20 reverse_string(s, length-n, length-1); 21 22 return s; 23 } 24 };
标签:字符串 height amp public color return star temp div
原文地址:https://www.cnblogs.com/ocpc/p/12859742.html