样例过,结果错

B3843 [GESP202306 三级] 密码合规

__HappY__ @ 2024-07-02 21:24:35


#include<bits/stdc++.h>
using namespace std;
string s;
const int N = 911;
char a[N];
int j = 1;
int letters, letterl, number, symbol;
int main() {
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != ',') {
            a[j] = s[i];
            j++;
            if(s[i] >= 'a' && s[i] <= 'z') 
                letters++;
            if(s[i] >= 'A' && s[i] <= 'Z') 
                letterl++;
            if(s[i] >= '0' && s[i] <= '9') 
                number++;
            if(s[i] == '!' || s[i] == '@' || s[i] == '#' || s[i] == '$') 
                symbol++;
        }
        if(s[i] == ',') {

            if(j >= 7 && j <= 13 && (letters != 0 && letterl != 0 || letters != 0 && number != 0 || letterl !=0 && number !=0) && symbol >= 1 && letters + letterl + number + symbol == j - 1) {
                for(int k = 1; k <= j; k++){
                    cout << a[k];
                }
                cout << endl;
            }
            j = 1;
            letters = 0;
            letterl = 0;
            number = 0;
            symbol = 0;
            memset(a, 0, sizeof(0));
        }
    }

    return 0;
}

by FLYAirbus @ 2024-07-02 21:28:39

@HappY 不多说但是头像是香拉??


by Disjoint_cat @ 2024-07-02 21:31:49

@HappY

for(int k = 1; k <= j; k++) \to for(int k = 1; k < j; k++)

另外笑点解析:sizeof(0)


by __HappY__ @ 2024-07-02 21:46:55

@FLYAirbus 那不重要


|