本人蒟蒻,0分求救!

B3843 [GESP202306 三级] 密码合规

lilili_114514 @ 2024-08-16 11:36:47

大佬,救救孩子吧!

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

by Mr_yang1 @ 2024-08-16 11:42:05

蒟蒻的低质写法

#include<bits/stdc++.h>
using namespace std;
string s;
bool hg(string sr){
    int dx=0,xx=0,sz=0,zf=0;
    for(int i=0;i<sr.length();i++){
        if(sr[i]<='z'&&sr[i]>='a'){
            xx=1;
        }
        else if(sr[i]<='Z'&&sr[i]>='A'){
            dx=1;
        }
        else if(sr[i]<='9'&&sr[i]>='0'){
            sz=1;
        }
        else if(sr[i]=='!'||sr[i]=='@'||sr[i]=='#'||sr[i]=='$'){
            zf=1;
        }
        else{
            return 0;
        }
    }
    if(zf==0)return 0;
    if(not(sr.length()>=6&&sr.length()<=12))return 0;
    if((dx+xx+sz)<2)return 0;
    return 1;
}
int main(){
    cin>>s;s+=',';
    string t="";
    for(int i=0;i<s.length();i++){
        if(s[i]!=','){
            t+=s[i];
        }
        else{
            if(hg(t)==1){
                cout<<t<<endl;
            }
            t="";
        }
    }
    return 0;
}

by Mr_yang1 @ 2024-08-16 11:47:50

@lilili_114514


by lilili_114514 @ 2024-08-16 11:53:05

@Mr_yang1 谢谢大佬,已关


by jeffrey120403 @ 2024-08-16 15:43:08

man


by lilili_114514 @ 2024-08-16 17:04:54

@jeffrey120403 肿么又是泥


by jeffrey120403 @ 2024-08-18 20:50:37

@lilili_114514 牢大我想你了????


by ___1 @ 2024-08-20 23:08:55

!?


|