5 solutions

  • 3
    @ 2025-10-7 15:59:04
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	string s;
    	cin>>s;
    	s=s+",";
    	while(s.find(",")!=-1)
    	{
    		int k=s.find(","); //找到位置 
    		string s1=s.substr(0,k); //截取前面的一段 
    		s.erase(0,k+1); //删除前面的一段 
    		if(s1.size()<6||s1.size()>12) //长度不符合 
    		{
    			continue;
    		}
    		int c1=0,c2=0,c3=0,c4=0;
    		bool st=true; 
    		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=1;
    				continue;
    			}
    			st=false;
    		}
    	//	cout<<st<<" "<<c1+c2+c3+c4<<endl;
    		if(st&&c1+c2+c3>=2&&c4==1)
    		{
    			cout<<s1<<endl;
    		}
    	}
    	return 0;
    }
    
    
    
    • 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;
      }
      
      
      
      • -1
        @ 2026-7-9 14:41:30
        #include<bits/stdc++.h>
        using namespace std;
        string s,str;
        int b[5];
        int main()
        {
            cin>>str;
            str+=',';
            for(int i=0;i<str.length();i++){
                if(str[i]!=','){
                    s+=str[i];
                    continue;
                }
                b[4]=1;
                int A=s.length();
                if(A<=12 && A>=6){
                    for(int j=0;j<A;j++){
                        if(s[j]<='Z' && s[j]>='A') b[1]=1;
                        else if(s[j]<='z' && s[j]>='a') b[0]=1;
                        else if(s[j]=='!' || s[j]=='@' || s[j]=='#' || s[j]=='$') b[3]=1;
                        else if(s[j]>='0' && s[j]<='9') b[2]=1;
                        else if(!(s[j]=='!' || s[j]=='@' || s[j]=='#' || s[j]=='$')) b[4]=0;
                    }
                    if(b[0]+b[1]+b[2]>=2 && b[3]==1 && b[4]==1){
                        cout<<s<<endl;
                    }
                }
                b[0]=b[1]=b[2]=b[3]=0;
                s="";
        
            }
            return 0;
        }
        
        
        
        • -1
          @ 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
            @ 2026-4-16 20:44:01

            • 1

            Information

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