wa了,很急,在线等

B3843 [GESP202306 三级] 密码合规

lihaoyang0317 @ 2025-01-01 09:38:14

#include<bits/stdc++.h>
using namespace std;
#define int long long
string a,t;bool c=1,xz,tz,sz,dz;
signed main()
{
    cin>>a;
    for(int i=0;i<a.length();i++)
    {
        if(a[i]==',')
        {
            if(!((xz&&dz||dz&&sz||sz&&xz)&&tz))
            {
                c=0;
                //cout<<"error1"<<" "; 
            }
            if(t.length()>=12&&t.length()<=6)
            {
                c=0;
                //cout<<"error2"<<" ";
            }
            //cout<<xz<<" "<<dz<<" "<<sz<<" "<<tz<<" "<<t.length()<<" "<<c<<endl;
            if(c)
            {
                cout<<t<<endl;
            }
            c=1;
            t="";
            continue;
        }
        t+=a[i];
        if('a'<=a[i]&&a[i]<='z'||'A'<=a[i]&&a[i]<='Z'||'0'<=a[i]&&a[i]<='9'||a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$');
        else 
        {
            c=0;
            //cout<<"error3"<<" ";
        }
        if('a'<=a[i]&&a[i]<='z')
        {
            xz=1;
        }
        if('A'<=a[i]&&a[i]<='Z')
        {
            dz=1;
        }
        if('0'<=a[i]&&a[i]<='9')
        {
            sz=1;
        }
        if(a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$') 
        {
            tz=1;
        }
    }
    return 0;
}

by lty2023 @ 2025-01-01 09:48:46

#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b="";
    getline(cin,a);
    for(int i=0;i<a.size();i++){
        if(a[i]==','){
            if(b.size()>=6&&b.size()<=12){
                bool s=0,x=0,d=0,t=0;
                for(int j=0;j<b.size();j++){
                    if(b[j]>='0'&&b[j]<='9'){
                        s=1;
                    }
                    if(b[j]>='a'&&b[j]<='z'){
                        x=1;
                    }
                    if(b[j]>='A'&&b[j]<='Z'){
                        d=1;
                    }
                    if(b[j]=='!'||b[j]=='@'||b[j]=='#'||b[j]=='$'){
                        t=1;
                    }
                }
                if(((s&&x)||(s&&d)||(x&&d))&&t){
                    cout<<b<<endl;
                }
            }
            b="";
        }
        else{
            b+=a[i];
        }
    }
}

by goldensand @ 2025-01-09 19:15:52

@lty2023 你这个虽然能ac,,但好像有些问题。 比如这组测试123&^YUhg@!,seHJ12!@,sjdkffH$123,sdf!@&12HDHa! 你的输出结果就不对


|