求助!!

B3843 [GESP202306 三级] 密码合规

liyuhang @ 2023-12-03 17:24:51

#include <bits/stdc++.h>
using namespace std;
string a;
string aa[100];
int len=0,kk=0,san=0,ts=0;
bool a1=false,a2=false,a3=false,io=true;
int main()
{
    cin>>a;
    for(int i=0;i<a.size();i++)
        if(a[i]==',')
        {
            for(int j=len;j<i;j++)
                aa[kk]=a[j];
            kk++;
            len=i+1;
        }   
    for(int i=0;i<=kk;i++)
    {
        if(aa[i].size()>6&&aa[i].size()<12)
        {
            for(int j=0;j<=aa[i].size();j++)
            {
                if(aa[j][i]<='z'&&aa[j][i]>='a'&&a1==false)     {san++;a1=true;}
                if(aa[j][i]<='Z'&&aa[j][i]>='A'&&!a2)   {san++;a2=true;}
                if(aa[j][i]<='0'&&aa[j][i]>='9'&&!a3)   {san++;a3=true;}
                if(aa[j][i]=='!'||aa[j][i]=='@'||aa[j][i]=='#'||aa[j][i]=='$'){ts++;}
                if(san>=2&&ts!=0) break;
                if((aa[j][i]<='z'&&aa[j][i]>='a')||(aa[j][i]<='Z'&&aa[j][i]>='A')||(aa[j][i]<='0'&&aa[j][i]>='9')||(aa[j][i]=='!'||aa[j][i]=='@'||aa[j][i]=='#'||aa[j][i]=='$'))
                continue;
                else
                    io=false;
            }
            if(io)
                cout<<aa[i]<<endl;
        }
    }
    return 0;
}

|