为什么报错啊?
  • 板块灌水区
  • 楼主封禁用户
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/12/2 18:43
  • 上次更新2024/12/2 21:04:14
查看原帖
为什么报错啊?
1013979
封禁用户楼主2024/12/2 18:43
#include<bits/stdc++.h>
using namespace std;
map<string,int> tong;
int main()
{
	string s;
	char a;
	cin>>s;
	int t=s.size();
	if(t%2==0)
	{
		bool flag=true;
		for(int i=1;i<=t/2;i++) if(s[i]!=s[2*i]-1||s[i]!=s[2*i]) flag=false;
	    if(flag==true)
	    {
	    	
			for(int j=1;j<=t;j++)
			{
				a=s[j];
			    tong[a]++;//这行报错
			}
	    	bool flag1=true;
	    	for(int j=1;j<=t;j++) if(tong[j]!=2&&tong[j]!=0) flag1=false;
		    if(flag1==true)
		    {
		    	cout<<"Yes";
			}
		    else
		    {
		    	cout<<"No";
			}
		}
		else
		{
			cout<<"No";
		}
	}
	else
	{
		cout<<"No";
	}
	
	return 0;
}
2024/12/2 18:43
加载中...