啊啊啊啊,为什么会错

B3843 [GESP202306 三级] 密码合规

zhangyakui @ 2024-05-22 21:21:50

代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int sum=0,sum1=0,sum2=0,sum3=0,sum4=0;
  bool flag=false; 
  string s;
  cin>>s;
    for(int i=0;i<s.size();i++)
      { 
         if(s[i]==',')
         {
         if(flag!=true&&i-sum>=6&&i-sum<=12&&sum1+sum2+sum3>=2&&sum4==1)
           {
              for(int j=sum;j<i;j++)
                cout<<s[j];
                cout<<'\n';
                sum=i+2;    
           }
                        flag=false;
                continue;
         }
         if(s[i]>='a'&&s[i]<='z')
         sum1=1;
         if(s[i]>='A'&&s[i]<='Z')
         sum2=1;
         if(s[i]>='0'&&s[i]<='9')    
         sum3=1;
         if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$')
         sum4=1;
         if(!(s[i]>='a'&&s[i]<='z')&&!(s[i]>='A'&&s[i]<='Z')&&!(s[i]>='0'&&s[i]<='9')&&(s[i]!='!'&&s[i]!='@'&&s[i]!='#'&&s[i]!='$'))
         flag=true; 
      }
      return 0;
} 

by osmium_dust @ 2024-05-28 13:04:28

没有考虑最后一个密码,sum都没有重置


|