// 字符串替换空格:请实现一个函数,把字符串中的每一个空格替换成"%20". // 比如输入"we are happy.",则输出"we%20are%20happy." #include <stdio.h> #include <assert.h> char* replace(char* p) { char* ret = p; int num = 0; int oldlen = 0; int newlen = 0; cha
public class Solution { public String replaceSpace(StringBuffer str) { String str1=str.toString(); char[] charArray = str1.toCharArray(); StringBuilder sBuilder = new StringBuilder(); for (char c : charArray) { if(c==' ') { sBuilder.append("%20"