class Solution{public:string replaceSpace(string s){int count=0,len= s.size();//统计空格的个数for(char c : s){if(c ==' ')count++;} s.resize(len + 2 * count);//修改字符串的长度for(int i = len-1, j =s.size()-1;i<j;i--,j--) {if(s[i]!=' ')s[j]=s[i];else{s[j]='0';s[j-1]='2';s[j-2]='%';j=j-2;}}return s;}
};