求调

B3843 [GESP202306 三级] 密码合规

molakeser @ 2024-09-17 10:46:01

#include <bits/stdc++.h>

using namespace std;
#define int long long

string s,s1;
bool tj1(string s){
    for(int i=0;i<s.size();i++){
        if(!isalnum(s[i])&&s[i]!='!'&&s[i]!='@'&&s[i]!='#'&&s[i]!='$')
            return 0;
    }
    return 1;
}
bool tj2(string s){
    if(s.size()<6||s.size()>12)
        return 0;
    return 1;
}
bool tj3(string s){
    int t1=0,t2=0,t3=0;
    for(int i=0;i<=s.size();i++){
        if(isalpha(s[i]))
            t1=1;
        if(isdigit(s[i]))
            t2=1;
        if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$')
            t3=1;
    }
    if(t1+t2>=2&&t3)
        return 1;
    return 0;
}
signed main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        char c=s[i];
        if(c!=','){
            s1+=c;
        }
        if(i==s.size()-1||c==','){
            if(tj1(s1)&&tj2(s1)&&tj3(s1))
                cout<<s1<<endl;
            s1="";
        }
    }
    return 0;
}

by BVV_d_ @ 2024-09-17 11:37:00

其实你可以用find_first_not_of("合法的所有字符“)


|