0pts求调

B3843 [GESP202306 三级] 密码合规

lym12 @ 2023-11-19 14:59:17

#include <bits/stdc++.h>
using namespace std;

string sv[105];
int main(){
    string s;
    getline(cin, s);

    string t = "";
    int cnt = 0;
    for (int i = 0; i < s.length(); i ++){
        if (s[i] == ',') sv[cnt ++] = t, t = "";
        else t += s[i];
    }
    sv[cnt ++] = t;

    for (int i = 0; i < cnt; i ++){
        t = sv[i];
        if (t.length() < 6 || t.length() > 12){
            cout << t << endl; continue;
        }

        int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
        for (char j : t){
            if (!(isdigit(j) || isalpha(j) || j == '!' || j == '@' || j == '#' || j == '$')){
                cout << t << endl;
                break;
            }else{
                c1 += islower(j), c2 += isupper(j), c3 += isdigit(j), c4 += j == '!' || j == '@' || j == '#' || j == '$';
            }
        }

        if (!((c1 > 0 && c2 > 0) || (c1 > 0 && c3 > 0) || (c2 > 0 && c3 > 0) && c4 > 0)){
            cout << t << endl;
            continue;
        }
    }
}

|