1 条题解

  • 1
    //初次尝试使用map,还望大佬多多指导
    #include<bits/stdc++.h>
    using namespace std;
    char s1[260],s2[260];
    map<char,bool>ch;
    int tot;
    char road;
    signed main()
    {
        ios::sync_with_stdio(false);
        cin>>s1>>s2;
        for(int i=0;i<strlen(s1);i++)
            for(int j=0;j<strlen(s2);j++)
                if(s1[i]==s2[j])
                {
                    bool f=1;
                    if(ch[s1[i]]==1)f=0;
                    ch[s1[i]]=1,road=s1[i];
                    if(f)tot++;
                }
        switch(tot)
        {
            case 0:cout<<"WuXiao"<<endl;break;
            case 1:cout<<"ZhiHui"<<endl<<road<<endl;break;
            default:
            {
                cout<<"XLuo"<<endl<<tot<<endl;
                for(char i='A';i<='Z';i++)
                {
                    if(ch[i])cout<<i,tot--;
                    if(tot&&ch[i])cout<<'-';
                }
                cout<<endl;
            }
        }
        return 0;
    }
    
    
    • @ 2024-01-06 17:29:48

      我一开始也想用map(看到你的题解之前)

  • 1

信息

ID
1963
难度
9
分类
(无)
标签
递交数
6
已通过
4
通过率
67%
被复制
3
上传者