求助大佬

B3843 [GESP202306 三级] 密码合规

l_jin @ 2024-06-30 18:08:59

#include<bits/stdc++.h>
using namespace std;
int cnt[11];
bool ifs(string s){
    if(s.length()<6 || s.length()>12)return 0;
    for(int i=0;i<s.length();i++){
        if(s[i]>='A' && s[i]<='Z')cnt[1]++;
        else if(s[i]>='a' && s[i]<='z')cnt[2]++;
        else if(s[i]>='0' && s[i]<='9')cnt[3]++;
        else if(s[i]=='!' || s[i]=='@' || s[i]=='#' || s[i]=='$')cnt[4]++;
        else return 0;
    }
    if(cnt[4]==0)return 0;
    int ans=0;
    for(int i=1;i<=3;i++){
        if(cnt[i]>0)ans++;
    }
    if(ans>=2)return 1;
}
int main(){
    string a;
    cin>>a;
    string s[105];
    int j=1;
    for(int i=0;i<a.length();i++){
        if(a[i]==','){
            j++;
            continue;
        }else{
            s[j]+=a[i];
        }
    }
    for(int i=1;i<=j;i++){
        if(ifs(s[i])){
            cout<<s[i]<<"\n";
        }
    }
    return 0;
}

哪里出问题了?


by Ivan422 @ 2024-07-15 17:58:17

看这个


by l_jin @ 2024-08-06 09:26:57

@Ivan422 感谢大佬


|