题解 | #单词替换#

单词替换

https://www.nowcoder.com/practice/5b58a04679d5419caf62c2b238e5c9c7

#include <bits/stdc++.h>
using namespace std;

int main(){
	string ss[100];
	string s1,s2;
	int i=0;
	while(cin>>ss[i++])
	{
		if(cin.get()=='\n') break;
	}
	cin>>s1>>s2;
	for(int j=0;j<i;j++)
	{
		if(ss[j]==s1) ss[j]=s2;
		cout<<ss[j];
		if(j==i-1) cout<<endl;
		else cout<<" ";
	}
	return 0;
}

全部评论

相关推荐

no_work_no...:大专三年最辛苦的应该是手机和电脑了吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务