0分求调

B3843 [GESP202306 三级] 密码合规

timmy2012 @ 2024-09-19 16:54:46

样例运行是对的,但是WA不知道为啥啊

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char c;
    string s="";
    while(cin>>c)
    {
        if(c!=',')
        {
            s+=c;
            continue;
        }
        if(s.size()>=6&&s.size()<=12)
        {
            int upper=0,lower=0,digit=0,_=0;
            for(int i=0;i<s.size();i++)
            {
                upper=max(upper,isupper(s[i]));
                lower=max(lower,islower(s[i]));
                digit=max(digit,isdigit(s[i]));
                if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$')
                {
                    _=1;
                }
                if(upper+lower+digit>=2&&_)
                {
                    cout<<s<<"\n";
                    s="";
                    continue;
                }
            }
        }
        s="";
    }
    return 0;
}

0元重金奖励


by andycode @ 2024-09-19 17:12:57

@timmy2012 调好了

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char c;
    string s="";
    while(cin>>c)
    {
        if(c!=',')
        {
            s+=c;
            continue;
        }
        if(s.size()>=6&&s.size()<=12)
        {
            int upper=0,lower=0,digit=0,_=0;
            for(int i=0;i<s.size();i++)
            {
                upper=max(upper,int(bool(isupper(s[i]))));
                lower=max(lower,int(bool(islower(s[i]))));
                digit=max(digit,int(bool(isdigit(s[i]))));
                if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$')
                {
                    _=1;
                }
                if(upper+lower+digit>=2&&_)
                {
                    cout<<s<<"\n";
                    s="";
                    break;
                }
            }
        }
        s="";
    }
    return 0;
}

by andycode @ 2024-09-19 17:13:57

@timmy2012 我不要奖金要个关注可以吗?(doge


by timmy2012 @ 2024-09-19 21:32:39

已关注,谢谢大佬


by timmy2012 @ 2024-09-19 21:32:51

@andycode


|