1 条题解

  • 0
    @ 2024-6-1 10:20:01
    # include <iostream>
    using namespace std
    string s
    bool check(string x){
        int a = 0, A = 0, d = 0, f = 0
        // 小写字母,大写字母,数字,符号
        for (int i=0
             i < x.length()
             i++){
            if (x[i] >= 'a' & &x[i] <= 'z'){
                a = 1
            }else if (x[i] >= 'A' & &x[i] <= 'Z'){
                A = 1
            }else if (x[i] >= '0' & &x[i] <= '9'){
                d = 1
            }else if (x[i] == '!' | |x[i] == '@' | |x[i] == '#' | |x[i] == '$'){
                f = 1
            }else {//其他字符,不合规
                   return false
                   }
        }
        if (f == 0) return false
        // 没有符号,不合规
        if (a+A+d < 2) return false
        // 大小写和数字少于两种,不合规
        return true
        // 其他情况合规,返回true
    }
    int main() {
        cin >> s
        string t = ""
        for (int i=0
             i < s.length()
             i++){
            if (s[i] != ','){//非逗号,加到字符串末尾
                             t += s[i]
                             }else {//遇到逗号
                                    if (check(t) == 1){//判断字符串是否合规
                                                       cout << t << endl
                                                       }
                                    t = ""
                                    // 清空,开始下一个字符串
                                    }
        }
        return 0
    }
    
    

    信息

    ID
    1296
    时间
    1000ms
    内存
    256MiB
    难度
    9
    标签
    递交数
    11
    已通过
    4
    上传者