2345A @ 2023-12-08 18:19:48
样例能过
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool pd(char b[105])
{
int a=0,c=0;
bool pd1=0,pd2=0,pd3=0,pd4=0;
a=strlen(b);
if(a<6||a>12)
return 0;
for(int i=0;i<a;i++)
{
if(b[i]>'a'&&b[i]<'z')
pd1=1;
else if(b[i]>'A'&&b[i]<'Z')
pd2=1;
else if(b[i]>'0'&&b[i]<'9')
pd3=1;
else if(b[i]=='!'||b[i]=='@'||b[i]=='#'||b[i]=='$')
pd4=1;
else
return 0;
c++;
}
if(pd1+pd2+pd3<2)
return 0;
if(pd4==0)
return 0;
if(c==a)
return 1;
}
int main()
{
//freopen("e:\\123\\111.txt","r",stdin);
int a=0,t=0,j=0;
string b;
char c[105]={0};
cin>>b;
a=b.size();
for(int i=0;i<a;i++)
{
if(b[i]!=',')
{
c[j]=b[i];
j++;
}
else
{
c[j]='\0';
if(pd(c))
cout<<c<<endl;
j=0;
}
}
if((j>0)&&pd(c))
{
c[j]='\0';//
cout<<c;
}
return 0;
}
by user_help @ 2023-12-09 19:04:23
你的bool类型一次判断完后没有初始化
by 2345A @ 2023-12-14 11:22:32
@user_help 谢谢!!!!
by wangchu2023 @ 2023-12-15 20:21:37
if(a<6||a>12) 这里是if(a<6&&a>12) ||是或 &&才是且
by lizeyuhello @ 2024-03-15 21:50:29
@wangchu2023 人家这里就是对的,不可能同时满足