样例过了,但是wa了,求助

B3843 [GESP202306 三级] 密码合规

ACshenwansan @ 2025-01-05 20:03:58

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
using namespace std;

bool check(string s)
{
    bool b1 = false, b2 = false, b3= false , b4= false;
    if(s.size() < 6 || s.size() > 12)   return false;

    for(int i = 0; i < s.size(); i ++)
    {
        if(s[i] >= 'a' && s[i] <= 'z')  b1 = true;
        else if(s[i] >= 'A' && s[i] <= 'Z')  b2 == true;
        else if(s[i] <= '9' && s[i] >= '0') b3 = true;
        else if(s[i] == '!' || s[i] == '@' || s[i] == '#' || s[i] == '$') b4 = true;
        else return false;
    }

    if(b1 + b2 + b3 >= 2 && b4) return true;
    return false;

}

int main()
{
    string str;
    cin>>str;
    int n = 1 ; 
    string s[101];

    string res;
    for(int i = 0;i < str.size() ;i ++)
    {

        if(str[i] != ',')
            res += str[i];
        else {
            s[n ++ ] = res;
            res.clear();
        }
    }
    s[n ++ ] = res;
    for(int i = 1 ;i < n ;i ++)
    {
        //cout<<s[i]<<endl;
        if(check(s[i])) cout<<s[i]<<endl;
    }
    if(check(s[n])) cout<<s[n];

}

by 4041nofoundGeoge @ 2025-01-05 20:18:06

@ACshenwansan你可以边输入字符串边 \text{check},把 \text{, getchar} 掉就行了。


by wurang @ 2025-01-05 20:18:53

你猜我看了多久

else if(s[i] >= 'A' && s[i] <= 'Z')  b2 == true;

多打了一个=
求关


by wurang @ 2025-01-05 20:54:37

@4041nofoundGeoge 不是这个问题


by 4041nofoundGeoge @ 2025-01-05 20:56:57

@wurang这个代码有点 辣眼睛,改一下最好


by ACshenwansan @ 2025-01-06 10:07:41

@wurang呜呜,就是多了个=,非常感谢


|