#include<iostream>
#include<sstream>
using namespace std;
string a[1000];
int main()
{
string str,a,b;
getline(cin,str);
cin>>a>>b;
stringstream ssin(str);//字符串流 从字符串中提取所需要的信息(拆分),需要什么就定义什么类型 下面定义的是string类型
string s;//相当于拆分的每一个单词
while(ssin>>s)
if(s==a) cout<<b<<' ';
else cout<<s<<' ';
return 0;
}
类指针,不会解决需改的词字符为一的情况
#include <cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
using namespace std;
int main(){
char a[200],b[105],c[105];
fgets(a,200,stdin);
scanf("%s %s",&b,&c);
int alen=strlen(a),blen=strlen(b),cnt=0,temp=0;
for(int i=0;i<alen;i++){
for(int j=0;j<blen;j++){
if(a[i+j]==b[j]){
cnt++;
if(cnt==blen){
printf("%s",c);
temp=blen;
}
}
}
cnt=0;
if(temp>0){
temp--;
continue;
}
printf("%c",a[i]);
}
return 0;
}