题解 | #单词替换#

单词替换

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;
}

全部评论

相关推荐

被小米连拒3次了
投递小米集团等公司10个岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享
爱睡觉的冰箱哥:你是我今晚见过的最美的牛客女孩
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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