A30581.单词替换
2025-09-04 21:07:25
发布于:江苏
0阅读
0回复
0点赞
STL万嵗!
#include <iostream>
#include <string>
#include <bits/stl_pair.h>
#include <vector>
using namespace std;
pair<string, string> mp;
vector<string> sent;
int main() {
string wd;
while (cin >> wd) sent.push_back(wd);
mp.second = sent.back(); sent.pop_back();
mp.first = sent.back(); sent.pop_back();
for (string &wd:sent) {
if (wd == mp.first) wd = mp.second;
cout << wd << ' ';
}
return 0;
}
这里空空如也
有帮助,赞一个