WA求助!!! 样例过了!!!

B3843 [GESP202306 三级] 密码合规

lghbc @ 2024-01-20 15:08:36

WA求助!!!

样例过了!!!

#include <bits/stdc++.h>
using namespace std;
string str1, str2;
bool flag = 1;
int ans1 = 0, ans2 = 0, ans3 = 0;

int main() {
    cin >> str1;
    str1 += ',';
    for (int i = 0; i < str1.size(); i++) {
        if (str1[i] != ',') {
            str2 += str1[i];
            if (isalnum(str1[i]) == 0 && str1[i] != '!' && str1[i] != '@' && str1[i] != '#' && str1[i] != '$')
                flag = 0;
            if (str1[i] >= '0' && str1[i] <= '9')
                ans1 = 1;
            if (str1[i] >= 'a' && str1[i] <= 'z')
                ans2 = 1;
            if (str1[i] >= 'A' && str1[i] <= 'Z')
                ans3 = 1;
        } else {
            if (str2.size() > 12 || str2.size() < 6)
                flag = 0;
            if (ans1 + ans2 + ans3 < 2)
                flag = 0;
            if (flag)
                cout << str2 << endl;
            flag = 1;
            str2 = "";
        }
    }
}

by lyc0424 @ 2024-02-21 15:39:29

我也想知道怎么做,因为我和你一样qwq


by SatoruXia @ 2024-03-09 19:38:06

连我Py党都卡在了这里!!!


|