谁来救救我!0分!

B3843 [GESP202306 三级] 密码合规

wyp20130701 @ 2024-06-21 18:10:01

#include <bits/stdc++.h>
using namespace std;
char s1[105],s2[105];
void check()
{
    int l = strlen(s2);
    int num = 0;bool flag1 = false,flag2 = false,flag3 = false,flag4 = false;
    for (int i = 0;i < l;i++)
    {
        if (s2[i] >= '0' && s2[i] <= '9')
        {
            flag1 = true;
        }
        if (s2[i] >= 'a' && s2[i] <= 'z')
        {
            flag2 = true;
        }
        if (s2[i] >= 'A' && s2[i] <= 'Z')
        {
            flag3 = true;
        }
        if (s2[i] == '$' || s2[i] == '#' || s2[i] == '@' || s2[i] == '!')
        {
            flag4 = true;
        }
        if ((s2[i] <= '0' || s2[i] >= '9') && (s2[i] <= 'a' || s2[i] >= 'z') && (s2[i] >= 'Z' || s2[i] <= 'A') && (s2[i] != '$' && s2[i] != '#' && s2[i] != '@' && s2[i] != '!'))
        {
            return ;
        }
    }
    if (l >= 6 && l <= 12)
    {
        if (flag1)
        {
            num++;
        }
        if (flag2)
        {
            num++;
        }
        if (flag3)
        {
            num++;
        }
        if (flag4)
        {
            num++;
        }
        if (num >= 2)
        {
            cout << s2 << endl;
            return;
        }
    }
}
int main()
{
    int i = 0,j = 0;
    cin >> s1;
    while (s1[j] != '\0')
    {
        if (s1[j] == ',')
        {
            check();
            s2[0] = '\0';
            i = -1;
        }
        else
        {
            s2[i] = s1[j];
        }
        i++;j++;
    }
    return 0;
}

by Betrayer_of_love @ 2024-06-21 21:47:45

@wyp20130701 不用谢


上一页 |