求助

B3843 [GESP202306 三级] 密码合规

yaobingfeng @ 2024-08-13 19:47:01

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
long long a[10000],chang,d,x,shu,teshu;
string s;
int main(){
    cin>>s;
    int l=s.size();
    int b=0,e=-1;
    for(int i=0;i<l;i++){
        e++;
        chang++;
        if(s[i]>='A'&&s[i]<='Z') d=1;
        if(s[i]>='a'&&s[i]<='z') x=1;
        if(s[i]>='0'&&s[i]<='9') shu=1;
        if(s[i]=='$'||s[i]=='#'||s[i]=='@'||s[i]=='!')teshu++;
        if(s[i]==','||e==l){
            if(chang<6||chang>12||(d+x+shu)<2||teshu==0){
                chang=0;
                d=0;
                x=0;
                shu=0;
                teshu=0;
                continue;
            }
            else{
                if(e+1!=l)e--;
                for(int j=b;j<=e;j++){
                    cout<<s[j];
                }
                cout<<endl;
                e++;
                chang=0;
                d=0;
                x=0;
                shu=0;
                teshu=0;
                b=e+1;
            }
        }
    }
    return 0;
}

by yaobingfeng @ 2024-08-13 20:06:10

改了下,现在是这样

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
long long a[10000],chang,d,x,shu,teshu;
string s;
int main(){
    cin>>s;
    int l=s.size();
    int b=0,e=-1;
    for(int i=0;i<l;i++){
        e++;
        chang++;
        if(s[i]>='A'&&s[i]<='Z') d=1;
        if(s[i]>='a'&&s[i]<='z') x=1;
        if(s[i]>='0'&&s[i]<='9') shu=1;
        if(s[i]=='$'||s[i]=='#'||s[i]=='@'||s[i]=='!')teshu=1;
        if(s[i]==','){
            if(chang<6||chang>12||(d+x+shu)<2||teshu==0){
                chang=0;
                d=0;
                x=0;
                b=e+1;
                shu=0;
                teshu=0;
                b=e+1;
                continue;
            }
            else{
                if(e+1!=l)e--;
                for(int j=b;j<=e;j++){
                    if(s[j]!=',')cout<<s[j];
                }
                cout<<endl;
                e++;
                chang=0;
                d=0;
                x=0;
                shu=0;
                teshu=0;
                b=e+1;
            }
        }
        if(e==l){
            if(e+1!=l)e--;
            for(int j=b;j<=e;j++){
                if(s[j]!=',')cout<<s[j];
            }
            e++;
            chang=0;
            d=0;
            x=0;
            shu=0;
            teshu=0;
            b=e+1;
        }
    }
    return 0;
}

|