样例过了,但是wa了,求助
查看原帖
样例过了,但是wa了,求助
901191
ACshenwansan楼主2025/1/5 20:03
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
using namespace std;

bool check(string s)
{
    bool b1 = false, b2 = false, b3= false , b4= false;
    if(s.size() < 6 || s.size() > 12)   return false;
    
    for(int i = 0; i < s.size(); i ++)
    {
        if(s[i] >= 'a' && s[i] <= 'z')  b1 = true;
        else if(s[i] >= 'A' && s[i] <= 'Z')  b2 == true;
        else if(s[i] <= '9' && s[i] >= '0') b3 = true;
        else if(s[i] == '!' || s[i] == '@' || s[i] == '#' || s[i] == '$') b4 = true;
        else return false;
    }
    

    if(b1 + b2 + b3 >= 2 && b4) return true;
    return false;

}

int main()
{
    string str;
    cin>>str;
    int n = 1 ; 
    string s[101];
    
    string res;
    for(int i = 0;i < str.size() ;i ++)
    {
        
        if(str[i] != ',')
            res += str[i];
        else {
            s[n ++ ] = res;
            res.clear();
        }
    }
    s[n ++ ] = res;
    for(int i = 1 ;i < n ;i ++)
    {
        //cout<<s[i]<<endl;
        if(check(s[i])) cout<<s[i]<<endl;
    }
    if(check(s[n])) cout<<s[n];
 
}
2025/1/5 20:03
加载中...