1 solutions

  • 2
    @ 2025-10-7 15:59:04
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        string s;
        cin>>s;
        s=s+',';
        int n=s.size();
        int last=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]==',')
            {
                string s1=s.substr(last,i-last);
                bool st=true;
    			if(s1.size()<6||s1.size()>12) //长度不符合要求 
    		    {
    		        st=false;
    		    }
    		    bool c1=0,c2=0,c3=0;
    		    int c4=0;
    		    for(int i=0;i<s1.size();i++)
    		    {
    		        if(s1[i]>='A'&&s1[i]<='Z')
    		        {
    		            c1=1;
    		            continue;
    		        }
    		        if(s1[i]>='a'&&s1[i]<='z')
    		        {
    		            c2=1;
    		            continue;
    		        }
    		        if(s1[i]>='0'&&s1[i]<='9')
    		        {
    		            c3=1;
    		            continue;
    		        }
    		        if(s1[i]=='!'||s1[i]=='@'||s1[i]=='#'||s1[i]=='$') //其它字符 
    		        {
    		            c4++;
    		            continue;
    		        }
    		        st=false;
    		    }
    		    int t=c1+c2+c3;
    		    if(t==0||c4<1) //没有数字或者是其它字符小于一个 
    		    {
    		       st=false;
    		    }
                if(st) //不合法 
                {
                    cout<<s1<<endl;
                }
                last=i+1; //移动到下个位置 
            }
        }
        return 0;
    }
    
    • 1

    Information

    ID
    1179
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    16
    Accepted
    4
    Uploaded By