0分求调

B3843 [GESP202306 三级] 密码合规

ANS900UVUAHA @ 2024-08-15 19:43:28

#include<bits/stdc++.h>
using namespace std;
string r;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>r;
    int A=r.size();
    string l="";
    bool h=true;
    for(int i=0;i<A;i++)
    {
        if(i+1==A-1)
        {
            l+=r[i+1];
            i++;
        }
        if(r[i]==','||i==A-1)
        {
            if(h)
            {
                cout<<l<<"\n";
            }
            h=true;
            l="";
            continue;
        }
        if(isalnum(r[i])||isalpha(r[i])||r[i]=='!'||r[i]=='@'||r[i]=='#'||r[i]=='$')
        {
            l+=r[i];
        }
        else
        {
            h=false;
        }
    }
    return 0;
}

|