0分求助QAQ

B3843 [GESP202306 三级] 密码合规

Johnson31 @ 2024-12-02 21:36:12

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

by THRONESEAL @ 2024-12-02 21:47:37

@Johnson31是不是abcde要初始化为零啊,我感觉别的没什么问题


by Johnson31 @ 2024-12-02 21:55:36

谢谢,以AC,必关


|