Write a method to replace all spaces in a string with ‘%20’
还是用比较核武的字符串流吧~~刚开始的题目还是比较简单的。
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(){
string st,buff;
getline(cin ,st);
stringstream ss(st);
ss>>buff;
cout<<buff;
while(ss>>buff)
cout<<"%20"<<buff;
}
使用C++替换字符串中所有空格为'%'和'2'的方法
528

被折叠的 条评论
为什么被折叠?



