20分,调了1小时,没一点用
查看原帖
20分,调了1小时,没一点用
1122172
lelaimc楼主2024/4/13 22:02

哪个大佬帮忙看一下,谢谢

#include<bits/stdc++.h>
using namespace std;
string a[201];
string s,d,w,h="";
int main()
{
	getline(cin,w);
	w=' '+w+' ';
	int num=1;
	for(int t=1;t<w.size()-1;)
	{
		if(w[t-1]==' ')
		{
			h="";
			while(w[t+1]!=' ')
			{
				if(t<w.size()-1)
				{
					h=h+w[t];
					t++;
				}
				else break; 
			}
			a[num]=h;
			num++;
		}
		else t++;
	}
    cin>>s;
    cin>>d;
    for(int e=1;e<num;e++)
    {
        if(a[e]==s) a[e]=d;
        cout<<a[e]<<" ";
    }
    return 0;
}
2024/4/13 22:02
加载中...