悬关!!!5分

B3843 [GESP202306 三级] 密码合规

Boston_Celtics @ 2024-12-06 18:34:10

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char c;
    bool f=1;
    string s="";
    while(cin>>c)
    {
        if(c==',')
        {
            if(f&&s.size()>=6&&s.size()<=12) cout<<s<<endl;
            f=1;
            s="";
            continue;
        }
        s+=c;
        if(c>='A'&&c<='Z') continue;
        if(c>='a'&&c<='z') continue;
        if(c>='0'&&c<='9') continue;
        if(c=='!'||c=='@'||c=='#'||c=='$') continue;
        f=0;
    }
    return 0;
}

by xyx404 @ 2024-12-06 18:38:15

@Boston_Celtics

大写字母,小写字母和数字必须至少有其中两种,以及至少有四个特殊字符中的一个。


by Boston_Celtics @ 2024-12-06 18:42:24

@xyx404 谢谢


by Boston_Celtics @ 2024-12-06 18:42:43

@xyx404 已关


by codebot @ 2024-12-06 18:54:44

#include <iostream>
#include <cstring> 
#include <string.h>
using namespace std;
int main()         
{                      
    char a[100], b[100];
    int i = 0, w = 0, j = 0, k, n, m;
    int snum = 0, bnum = 0, num = 0, onum = 0;
    bool flag = true;
    cin >> a;

    //cout << a << endl;
    m = strlen(a);
    a[m] = ',';
    for (n = 0 ; n <= m ; n++){
        if (a[n] != ','){
            b[j] = a[n];
            b[j + 1] = '\0';
            w++;
            j++;
        }
        // cout << a[n] << endl;
        if (a[n] >= 97 && a[n] <= 122){
            snum = 1;  
        }
        else if (a[n] >= 65 && a[n] <= 90){
            bnum = 1;  
        }
        else if (a[n] >= '0' && a[n] <= '9'){
            num = 1;   
        } 
        else if (a[n] != '!' && a[n] != '@' && a[n] != '#' && a[n] !='$' && a[n] != ',') {
            flag = false;
        }
        if (a[n] == ','){
            j = 0;  
//          cout << b << endl;
            if (w - 1 <= 12 && w - 1 >= 6){
//              cout << "snum: " << snum << endl << "bnum: " << bnum << endl << "num: " << num << endl << "onum: " << onum << endl << "w: " << w << endl;  
//              cout << "flag: " << flag << endl;
                if (snum + bnum + num >= 2 && flag){
                    //Answer Output
                    cout << b;
                    cout << endl;
                }      
            }
            snum = bnum = num = onum = 0;
            memset(b, '\0', sizeof(b));
            w = 0;
            flag = true;
        }

        // cout << b << endl;           
    }
}

|