0分求助!!!

B3843 [GESP202306 三级] 密码合规

Ken369 @ 2024-12-02 19:15:40

大佬帮帮忙!!!

//@XiaoZheng
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
//if you need the test,you can look at the line 85

//main
int main()
{
    char a[101];
    char put[101];
    string str_input;
    int i=0,len=0;
    bool b_big=false,b_small=false,b_number=false,b_special=false;  //the flag
    bool b_wrong=false;
    //gets
    gets(a);
    //lenth
    int lenth=strlen(a);
    //Debug
    /*for(i=0;i<lenth;i++)
    {
        cout<<a[i];
    }
    cout<<endl;*/
    //the first to the a-1 one
    for(i=0;i<lenth;i++)
    {
        put[len]=a[i];
        //if
        if(a[i]>='A'&&a[i]<='Z')
        {
            b_big=true;
            len++;
        }
        else if(a[i]>='a'&&a[i]<='z')
        {
            b_small=true;
            len++;
        }
        else if(a[i]>='0'&&a[i]<='9')
        {
            b_number=true;
            len++;
        }
        else if(a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$')
        {
            b_special=true;
            len++;
        }
        else if(a[i]==','||i==lenth-1)  //we will print the right sentences here
        {
            if(((b_big&&b_small)||(b_big&&b_number)||(b_small&&b_number))&&b_special&&(len>=6&&len<=12)&&!b_wrong)
            {
                if(a[i]==',')
                {
                    for(int j=0;j<len-1;j++)
                    {
                        cout<<put[j];
                    }
                    cout<<endl;
                }
                else if(i==lenth)
                {
                    for(int j=0;j<len;j++)
                    {
                        cout<<put[j];
                    }
                    cout<<endl;
                }
            }
            else
            {
                //cout<<"wrong format"<<endl;   //debug
            }
            len=0;
            b_big=false;
            b_small=false;
            b_number=false;
            b_special=false;
            b_wrong=false;
            //cout<<i<<endl;    //debug
        }
        else
        {
            b_wrong=true;
            len++;
        }       
    }
    //the last one(don't forget it ^-^)-but I don't need it,because I have the line 47
    /*if(((b_big&&b_small)||(b_big&&b_number)||(b_small&&b_number))&&b_special&&(len>=6&&len<=12)&&!b_wrong)
    {
        for(int j=0;j<len;j++)
        {
            cout<<put[j];
        }
        cout<<endl;
    }*/
    // 
    //don't forget the "return"!
    return 0;
}
//I think you will need the test(down!)
//(test)->seHJ12!@,sjdkffH$123,sdf!@&12HDHa!,123&^YUhg@!,aA123456@

by MSJ2013 @ 2024-12-02 19:46:01

~我看不懂你代码~ AC代码


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=0;
    int c=0,d=0,e=0,f=0,g=0,h=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=','){
            g++;
            if(s[i]>='A'&&s[i]<='Z'){
                c=1;
            }else if(s[i]>='a'&&s[i]<='z'){
                d=1;
            }else if(s[i]>='0'&&s[i]<='9'){
                e=1;
            }else if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$'){
                f=1;
            }else{
                h=1;
            }
        } if(s[i]==','||i+1==s.size()){
            if(g>=6&&g<=12&&c+d+e>=2&&f&&!h){
                if(i+1==s.size()) i++;
                for(int j=a;j<i;j++){
                    cout<<s[j];
                }
                cout<<endl;
            }
            c=0,d=0,e=0,f=0,g=0,h=0;
            a=i+1;
        }
    }
    return 0;
}

by Ken369 @ 2024-12-03 19:58:22

谢大佬!!!


by Ken369 @ 2024-12-03 19:59:34

@MSJ2013


|