WA求调,样例过

B3843 [GESP202306 三级] 密码合规

cza2023 @ 2024-01-04 21:47:59

#include<bits/stdc++.h>
using namespace std;
string a[101];
bool pd(string s){
    bool upper=0,lower=0,num=0;
    if(s.size()<6||s.size()>12)return false;
    for(int i=0;i<s.size();i++){
        if(!isalnum(s[i])&&s[i]!='!'&&s[i]!='@'&&s[i]!='#'&&s[i]!='$')return false;
        if(isupper(s[i]))upper=1;
        if(islower(s[i]))lower=1;
        if(isdigit(s[i]))num=1;
    }
    return (upper&&lower)||(upper&&num)||(lower&&num);
}
int main(){
    string s,b="";
    int c=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]==',')a[++c]=b,b="";
        else b+=s[i];
    }
    a[++c]=b;
    for(int i=1;i<=c;i++){
        if(pd(a[i])){
            cout<<a[i]<<"\n";
        }
    } 
}

|