0分,求助! !(qwq)

B3843 [GESP202306 三级] 密码合规

zhaochenyou__funina @ 2024-08-30 23:50:42

#include<bits/stdc++.h>
using namespace std;
string a,str="";
bool check1(string a)
{
    int up,low,num,sym;
    for(int i=0;i<=a.size()-1;i++)
    {
        if(a[i]>='a' && a[i]<='z') 
        {
            low=1;
            continue;
        }
        if(a[i]>='A' && a[i]<='Z') 
        {
            up=1;
            continue;
        }
        if(a[i]>='0' && a[i]<='9') 
        {
            num=1;
            continue;
        }
        if(a[i]=='!' || a[i]=='@' || a[i]=='#' || a[i]=='$') 
        {
            sym++;
            continue;
        }
    }
    return !((low+up+num>=2) && sym);
}
bool check2(string a)
{
    for(int i=0;i<=a.size()-1;i++)
    {
        if(a[i]>='a' && a[i]<='z') continue;
        if(a[i]>='A' && a[i]<='Z') continue;
        if(a[i]>='0' && a[i]<='9') continue;
        if(a[i]=='!' || a[i]=='@' || a[i]=='#' || a[i]=='$') continue;
        return 1;
    }
    return 0;
}
int main()
{
    cin>>a;
    a=a+' ';
    for(int i=0;i<=a.size()-1;i++)
    {
        if(a[i]==',' || a[i]==' ')
        {
            if(str.size()<=6 || str.size()>=12) continue;
            if(check2(str)) continue;
            if(check1(str)) continue;
            cout<<str<<endl; 
            str="";
        }
        else str+=a[i];
    }
}

by tianyun4188awa @ 2024-08-30 23:55:59

char line[101];
 char pwd[101];
bool check(char * str, int l) {
 if (l < 6 || l > 12)
 return false;
 bool hasC = false, hasL = false, hasD = false, hasS = false;
 for (int i = 0; str[i] != '\0'; i++) {
 if ('A' <= str[i] && str[i] <= 'Z') {
 hasC = true;
 } else if ('a' <= str[i] && str[i] <= 'z') {
 hasL = true;
 } else if ('0' <= str[i] && str[i] <= '9') {
 hasD = true;
 } else if (str[i] == '!' || str[i] == '@' ||
 str[i] == '#' || str[i] == '$') {
 hasS = true;
 } else
 return false;
 }
 if (!hasS)
 return false;
 if (hasC + hasL + hasD < 2)
 return false;
 return true;
 }
 int main() {
 cin >> line;
 // 按逗号对输入进行切分,并依次判断
int len = 0;
 for (int i = 0; line[i] != '\0'; i++) {
 if (line[i] != ',') {
 pwd[len] = line[i];
 len++;
 } else {
 pwd[len] = '\0';
 if (check(pwd, len))
 cout << pwd << endl;
 len = 0;
 }
 }
 if (len > 0) {
 pwd[len] = '\0';
if (check(pwd, len))
 cout << pwd << endl;
 }
 return 0;
}

帮帮你大佬,您帮帮我那篇求助b3636可以吗谢谢大佬


by zhaochenyou__funina @ 2024-08-31 11:11:53

@tianyun4188awa

我帮你看看吧

其实我很弱的(qwq)


|