经典指数          
原因
2040
浏览数
0
收藏数
 

把字符串S中所有A子串换成B。

     举报   纠错  
 
切换
1 个答案

// c++

void replaceA_to_B(std::string& S, const std::string A, const std::string B){

std::size_t found = S.find(A);

while (std::string::npos != found) {

S.replace(found, A.length(), B);

found = S.find(A, found + 1);

}

}

 
切换
撰写答案