求~救!

B3843 [GESP202306 三级] 密码合规

MIAOQINGTIAN @ 2024-03-12 20:29:21

自己编的和样例都过了,求助!!!```cpp

include <bits/stdc++.h>

using namespace std; int main() { string a; cin >> a; int f=0,wz=0; for(int i=0;i<a.size();i++) { if(a[i]==',') { if(f==1) { f=0; } else if(f==0) { for(int j=wz;j<i;j++) { cout << a[j]; } cout << endl; wz=i+1; } } else if(!((a[i]>='a' && a[i]<='z') || (a[i]>='A' && a[i]<='Z') || (a[i]<='9' && a[i]>='0') || a[i]=='!' || a[i]=='@' || a[i]=='#' || a[i]=='')) { f=1; } } int flag=0; for(int i=wz;i<a.size();i++) { if(!((a[i]>='a' && a[i]<='z') || (a[i]>='A' && a[i]<='Z') || (a[i]<='9' && a[i]>='0') || a[i]=='!' || a[i]=='@' || a[i]=='#' || a[i]=='')) { flag=1; break; } } if(flag==0) { for(int i=wz;i<a.size();i++) { cout << a[i]; } cout << endl; } return 0; }


by MIAOQINGTIAN @ 2024-03-12 20:30:03

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin >> a;
    int f=0,wz=0;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]==',')
        {
            if(f==1)
            {
                f=0;
            }
            else if(f==0)
            {
                for(int j=wz;j<i;j++)
                {
                    cout << a[j];
                }
                cout << endl;
                wz=i+1;
            }
        }
        else if(!((a[i]>='a' && a[i]<='z') || (a[i]>='A' && a[i]<='Z') || (a[i]<='9' && a[i]>='0') || a[i]=='!' || a[i]=='@' || a[i]=='#' || a[i]=='$'))
        {
            f=1;
        }
    }
    int flag=0;
    for(int i=wz;i<a.size();i++)
    {
        if(!((a[i]>='a' && a[i]<='z') || (a[i]>='A' && a[i]<='Z') || (a[i]<='9' && a[i]>='0') || a[i]=='!' || a[i]=='@' || a[i]=='#' || a[i]=='$'))
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
    {
        for(int i=wz;i<a.size();i++)
        {
            cout << a[i];
        }
        cout << endl;
    }
    return 0;
}

以上是代码


|