使用了stringstream,之前没有见过
#include <bits/stdc++.h>
using namespace std;
int main ()
{
string str ;
getline (cin , str);
string a, b;
cin >> a >> b;
stringstream ssin (str);
string s;
while (ssin >> s)
{
if (s == a) cout << b << ' ';
else cout << s << ' ';
}
return 0;
}
同样,char也有类似操作