4 solutions

  • 1
    @ 2026-4-25 21:58:28
    #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]==',')
            {
            	continue; 
            }
            int j=i;
            while(j<n&&s[j]!=',') j++;
            j--;
         	string s1=s.substr(i,j-i+1);
            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<=1||c4<1) //没有数字或者是其它字符小于一个 
    	    {
    	       st=false;
    	    }
            if(st) //不合法 
            {
                cout<<s1<<endl;
            }
         	i=j; 
        }
        return 0;
    }
    
    
    

    Information

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