哪错了

B3843 [GESP202306 三级] 密码合规

yuxinrui0618 @ 2024-07-29 13:14:01

#include<bits/stdc++.h>
using namespace std;
int hegui(string x)
{
    if (x.size()>12 || x.size()<6) return 0;
    int s=0,s1=0,s2=0,s3=0;
    for (int i=0;i<x.size();i++)
    {
        if (x[i]>='A' && x[i]<='Z')
            s=1;
        else if (x[i]>='a' && x[i]<='z')
            s1=1;
        else if (x[i]>='1' && x[i]<='9')
            s2=1;
        else if (x[i]=='!' || x[i]=='@' || x[i]=='#' || x[i]=='$')
            s3=1;
        else
            return 0;
    }
    if (s3 && s+s1+s2>=2)
        return 1;
    return 0;
}
int main(){
    string s;
    int p=0;
    cin>>s;
    for (int i=0;i<s.size();i++)
    {
        if (s[i]==',')
        {
            string x=s.substr(p,i-p);
            if (hegui(x))
                cout<<x<<endl;
            p=i+1;
        }
        if (i==s.size()-1)
        {
            string x=s.substr(p,i-p+1);
            if (hegui(x))
                cout<<x<<endl;
        }
    }
    return 0;
}

by yuxinrui0618 @ 2024-07-29 18:05:23

样例对的,提交0分,大佬们帮忙看看啊!!!


by arronchen @ 2024-07-31 16:22:55

@yuxinrui0618

  1. 题目要求的是0-9 10个数字

by yuxinrui0618 @ 2024-07-31 16:48:54

哦,谢谢!!!


|