3 solutions

  • 3
    @ 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]==',')
            {
            	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;
    }
    
    
    • 1
      @ 2026-4-16 20:44:01

      • 0
        @ 2026-4-16 21:36:36
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
        	string s;
        	cin>>s;
        	int l=s.size();
        	for(int i=0;i<l;i++)
        	{
        		if(s[i]==',') continue;
        		int j=i;
        		while(j<l&&s[j]!=',') j++;
        		j--;
        		string s1=s.substr(i,j-i+1);
        		bool f=true;
        		if(s1.size()<6||s1.size()>12)
        		{
        			f=false;
        		}
        		//cout<<f<<endl;
        		bool c1=0,c2=0,c3=0,c4=0;
        		int s4=0;
        		for(int i=0;i<s1.size();i++)
        		{
        			if(s1[i]>='A'&&s1[i]<='Z')
        			{
        				c1=1;
        			}
        			else if(s1[i]>='a'&&s1[i]<='z')
        			{
        				c2=1;
        			}
        			else if(s1[i]>='0'&&s1[i]<='9')
        			{
        				c3=1;
        			}
        			else if(s1[i]=='@'||s1[i]=='!'||s1[i]=='#'||s1[i]=='$')
        			{
        				c4=1;
        			}
        			else{
        				f=false;
        			}
        		}
        		//cout<<c1<<" "<<c2<<" "<<c3<<" "<<f<<endl;
        		s4=c1+c2+c3;
        		if((s4>=2&&c4>=1)&&f)
        		{
        			cout<<s1<<endl;
        		}
        		i=j;	
        	}
        	return 0;
        }
        
        • 1

        Information

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