为什么过不了!

B3843 [GESP202306 三级] 密码合规

yonglooksanlivi @ 2024-12-10 20:54:22

样例和自造的都能随便过,但是就WA

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

int sum = 1, flag = -1;
int len, lenb[150];
char a[150];
string b[150];
int cha, da, xi, shu, te, cuo;

int main() {
    cin >> a;
    len = strlen(a);
    for (int i = 0; i < len; i++) {
        if (a[i] == ',') {
            sum++;
        }
    }
    for (int i = 0; i < sum; i++) {
        for (int j = flag + 1; j < len; j++) {
            if (a[j] != ',') {
                b[i] += a[j];
            } else {
                flag = j;
                break;
            }
        }
    }
    for (int i = 0; i < sum; i++) {
        lenb[i] = b[i].length();
        for (int j = 0; j < lenb[i]; j++) {
            if (lenb[i] < 6 || lenb[i] > 12 ) {
                cha = 1;
            }
            if (b[i][j] > '@' && b[i][j] < '[') {
                da = 1;
            } else if (b[i][j] > '`' && b[i][j] < '{') {
                xi = 1;
            } else if (b[i][j] == '!' || b[i][j] == '@' || b[i][j] == '#' || b[i][j] == '$') {
                te = 1;
            } else if (b[i][j] > '/' && b[i][j] < ':'){
                shu = 1;
            } else {
                cuo = 1;
            }
            if (cha != 1) {
                if ((da == 1 && xi == 1 && te == 1) || (shu == 1 && xi == 1 && te == 1) || (da == 1 && shu == 1 && te == 1)) {
                    if (cuo != 1) {
                        cout << b[i] << endl;
                        da = 0, xi = 0, shu = 0, te = 0, cuo = 0;
                        break;
                    }
                }
            }
        }
    }
    return 0;
}

虽然有点复杂了,但是蒟蒻我觉得思路很清晰


by pl_er @ 2024-12-10 21:19:15

兄弟你输出位置是不是放错了


|