0分求助

B3843 [GESP202306 三级] 密码合规

zhengyue2011 @ 2024-08-16 08:12:25

求调

#include <iostream>
using namespace std;
string s;
bool check(string x){
    int a=0,A=0,d=0,f=0;
    for(int i=0;i<x.length();i++){
        if(x[i]>='a'&&x[i]<='z'){
            a=1;
        }else if(x[i]>='A'&&x[i]<='Z'){
            A=1;
        }else if(x[i]>='0'&&x[i]<='9'){
            d=1;
        }else if (x[i]=='!'||x[i]=='@'||x[i]=='#'||x[i]=='$'){
            f=1;
        }else{
            return false;
        }
    }
    if (f==0) return false;
    if (a+A+d<2) return false;
    return true;
}
int main() {
    cin>>s;
    string t="";
    for(int i=0;i<s.length();i++){
        if (s[i]!=','){
            t+=s[i];
        }
        else{
            if (check(t)==1){
                cout<<t<<endl;
            }
            t="";
        }
    }
    return 0;
}

by FJ_00460 @ 2024-08-16 08:14:15

qp


by tangrundong @ 2024-08-16 08:19:35

6~12长度的字符没判


|