蒟蒻求助
  • 板块P1597 语句解析
  • 楼主ldxx26
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/9/15 13:20
  • 上次更新2023/11/2 20:47:05
查看原帖
蒟蒻求助
705996
ldxx26楼主2023/9/15 13:20

出的数据答案全对,可是为什么WA声一片!!!

#include<bits/stdc++.h>
using namespace std;
string a[3]={"0","0","0"};
bool h=0;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='='&&s[i-1]==':')
		{
			if(s[i+1]!='a'&&s[i+1]!='b'&&s[i+1]!='c')
			{
				int j=i+1;
				while(s[j]!=';')
				{
					a[s[i-2]-'a']+=s[j];
					j++;
				}
			}
			else a[s[i-2]-'a']=a[s[i+1]-'a'];
		}
	}
	for(int i=0;i<3;i++)
	{
		string t=a[i];
		h=0;
		for(int k=0;k<t.size();k++)
		{
			if(t[k]!='0')cout<<t[k],h=1;
			else if(t[k]=='0'&&h>0)cout<<t[k];
		}
		if(h==0)cout<<0;
		cout<<" ";
	}
	return 0;
}
2023/9/15 13:20
加载中...