1 条题解

  • 0
    @ 2026-4-19 20:37:12

    #include #include #include

    using namespace std; vector split(const string &s, char delimiter) { vector tokens; string token; for (char c : s) { if (c == delimiter) { if (!token.empty()) { tokens.push_back(token); token.clear(); } } else { token += c; } } if (!token.empty()) { tokens.push_back(token); } return tokens; }

    bool isValidPassword(const string &password) { if (password.length() < 6 || password.length() > 12) { return false; }

    bool hasLower = false, hasUpper = false, hasDigit = false, hasSpecial = false;
    
    for (char c : password) {
        if (islower(c)) {
            hasLower = true;
        } else if (isupper(c)) {
            hasUpper = true;
        } else if (isdigit(c)) {
            hasDigit = true;
        } else if (c == '!' || c == '@' || c == '#' || c == '$') {
            hasSpecial = true;
        } else {
            return false;
        }
    }
    
    int typeCount = 0;
    if (hasLower) typeCount++;
    if (hasUpper) typeCount++;
    if (hasDigit) typeCount++;
    
    return typeCount >= 2 && hasSpecial;
    

    }

    int main() { string input; getline(cin, input); if (input.length()>100){ input=input.substr(0,100);}

    vector<string> passwords = split(input, ',');
    for (const string &password : passwords) {
        if (isValidPassword(password)) {
            cout << password << endl;
        }
    }
    
    return 0;
    

    }

    信息

    ID
    3303
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    124
    已通过
    26
    上传者