0分,求调!!!!!!!!!!!!!!!!

B3843 [GESP202306 三级] 密码合规

zhanghaoyu1234567890 @ 2024-10-04 21:22:14

#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[101];
    cin>>a;
    char* b=a;
    int len=strlen(b);
    for(int i=0;i<len;i++){
        int l=i;
        bool flag=true;
        while(i<len&&a[i]!=','){
            if(!((a[i]>='A'&&a[i]<='Z')||(a[i]>='a'&&a[i]<='z')||(a[i]>='0'&&a[i]<='9')||a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$')){
                flag=false;
                break;
            }
            i++;
        }
        if(flag&&i-l>5&&i-l<13){
            for(int j=l;j<i;j++) cout<<a[j];
            cout<<endl;
        }
        while(i<len&&a[i]!=','){
            i++;
        }
    }
    return 0;
}

样例过了,0分求调{{{(>_<)}}}


by kkksc_tbh @ 2024-10-04 21:34:18

#include<bits/stdc++.h>
#define int long long
using namespace std;
string s,t; 
bool check(string s){
    if(s.size()<6||s.size()>12) return false;
    int a=0,b=0,c=0,d=0; 
    for(int i=0;i<s.size();i++)
    {
        if(s[i]>='0'&&s[i]<='9') a=1;
        else if(s[i]>='a'&&s[i]<='z') b=1;
        else if(s[i]>='A'&&s[i]<='Z') c=1;
        else if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$') d=1;
        else return false;
    }
    if(a+b+c>=2&&d==1) return true; 
    return false;
}
signed main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]==','){
            if(check(t))cout<<t<<endl;
            t="";
        }
        else t+=s[i];
    }
    if(check(t)) cout<<t;
    return 0;
}

check函数用来判断密码是否合规。main函数下面来分段密码,调用函数判断。


by zhanghaoyu1234567890 @ 2024-10-04 21:36:43

@tanbohan 谢谢


by kkksc_tbh @ 2024-10-04 21:44:42

@zhanghaoyu1234567890 不用谢


|