求调

B3843 [GESP202306 三级] 密码合规

lxc129 @ 2024-09-18 22:26:50

#include<bits/stdc++.h>
using namespace std;
string s;
vector<char>v;
bool is(char c){
    if (c>='A' && c<='Z') return 1;
    if (c>='a' && c<='z') return 1;
    if (c>='0' && c<='9') return 1;
    if (c=='!' || c=='@' || c=='#' || c=='$') return 1;
    return 0;
}
int main(){
    //freopen("Password_compliance.in","r",stdin);
    //freopen("Password_compliance.out","w",stdout);
    cin>>s;
    for (int i=0;i<s.size();i++){
        while (s[i]!=',') v.push_back(s[i]),i++;
        bool flag=1;
        for (int j=0;j<v.size();j++)
            if (!is(v[j])){
                flag=0;
                break;
            }
        if (flag==1) for (int j=0;j<v.size();j++) cout<<v[j];
        v.clear();
        cout<<'\n';
    }
    bool flag=1;
    for (int i=0;i<v.size();i++)
        if (!is(v[i])){
            flag=0;
            break;
        }
    if (flag==1) for (int i=0;i<v.size();i++) cout<<v[i];
}

备注:因为最近在复习csp,所以要写freopen


|