help!!!

B3843 [GESP202306 三级] 密码合规

luoyiwen @ 2024-11-28 22:06:47

#include <bits/stdc++.h>
using namespace std;
long long t,sz,zm,d,x,ts,sum;
string s; 
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==',')
        {
            sum++;
            if(t>=6&&t<=12&&x+d+sz>=2&&zm==1)
            {
                if(sum>=2) cout<<endl;
                for(int j=i-t;s[j]!=',';j++) cout<<s[j];
            }
            zm=0;
            d=0;
            x=0;
            t=0;
            sz=0;
            continue;
        }
        if(s[i]=='@'||s[i]=='!'||s[i]=='#'||s[i]=='$') zm=1;
        if(s[i]>='a'&&s[i]<='z') x=1;
        if(s[i]>='A'&&s[i]<='Z') d=1;
        if(s[i]>='0'&&s[i]<='9') sz=1;
        t++;
    }
    return 0;
}

by caoyichen1 @ 2024-12-01 16:48:11

#include<bits/stdc++.h>
using namespace std;
bool judge_whether_the_password_is_compliant(string m,int t)
{
    if (t<6||t>12)
    {
        return 0;
    }
    bool does_the_capital_letter_match=0,do_lowercase_letters_match=0,does_the_figure_match=0,does_the_special_character_match=0;
    for (int i=0;m[i]!='\0';i++)
    {
        if (m[i]>='A'&&m[i]<='Z')
        {
            does_the_capital_letter_match=1;
        }
        else if(m[i]>='a'&&m[i]<='z')
        {
            do_lowercase_letters_match=1;
        }
        else if(m[i]>='0'&&m[i]<='9')
        {
            does_the_figure_match=1;
        }
        else if(m[i]=='!'||m[i]=='@'||m[i]=='#'||m[i]=='$')
        {
            does_the_special_character_match=1;
        }
        else
        {
            return 0;
        }
    }
    if (!does_the_special_character_match||does_the_capital_letter_match+do_lowercase_letters_match+does_the_figure_match<2)
    {
        return 0;
    }
    return 1;
}
int main()
{
    char n[102],m[102];
    int t=0;
    cin>>n;
    for (int i=0;n[i]!='\0';i++)
    {
        if (n[i]!=',')
        {
            m[t]=n[i];
            t++;
        }
        else
        {
            m[t]='\0';
            if (judge_whether_the_password_is_compliant(m,t))
            {
                cout<<m<<endl;
            }
            t=0;
        }
    }
    if (t>0)
    {
        m[t]='\0';
        if (judge_whether_the_password_is_compliant(m,t))
        {
            cout<<m;
        }
    }
    return 0;
}

|