C++ 代码 (steal and imitate with others)
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
string s[110];
string a, b;
int i = 0;
for(;; i++)
{
cin >> s[i];
char x = getchar();
if(x == '\n')
break;
}
cin >> a >> b;
for(int j = 0; j <= i; j++)
{
if(a == s[j])
s[j] = b;
cout << s[j] << ' ';
}
//配对连续出现的单词,用字符串数组果然简单!!
}