Jared0503 @ 2023-12-11 13:37:16
#include<bits/stdc++.h>
using namespace std;
struct bin{ //瞎写的结构体,不要笑,功能呢和字符串数组差不多
string s;
}k[100];
bool check(string s)
{
bool re[4]={0};
int len=s.size(),i=0,cnt;
for(;i<len;i++)
{
if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$') re[0]=1;
else if(s[i]>='A'&&s[i]<='Z') re[1]=1;
else if(s[i]>='a'&&s[i]<='z') re[2]=1;
else if(s[i]>='0'&&s[i]<='9') re[3]=1;
}
cnt=re[1]+re[2]+re[3];
// cout<<cnt;
return (re[0]==1&&cnt>=2);
}
int main()
{
int i=-1,num=-1;
char c;
string s="";
while(cin>>c)
{
if(c==',')
{
// cout<<s;
if(s.size()>12||s.size()<6) k[++num].s=s;
else if(!check(s)) k[++num].s=s;
s="";
continue;
}
s+=c;
}
// cout<<s;
if(s.size()>12||s.size()<6) k[++num].s=s;
else if(!check(s)) k[++num].s=s;
for(i=0;i<num;i++) cout<<k[i].s<<endl;
}
by DeusExMachina @ 2023-12-11 14:03:59
@Jared0503 几个问题
by DeusExMachina @ 2023-12-11 14:05:22
bool check(string s)
{
bool re[4]={1, 0, 0, 0};
int len=s.size(),i=0,cnt;
for(;i<len;i++)
{
if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$') continue;
else if(s[i]>='A'&&s[i]<='Z') re[1]=1;
else if(s[i]>='a'&&s[i]<='z') re[2]=1;
else if(s[i]>='0'&&s[i]<='9') re[3]=1;
else re[0] = 0;
}
cnt=re[1]+re[2]+re[3];
// cout<<cnt;
return (re[0]==1&&cnt>=2);
}
和
if(s.size()<12 && s.size()>6 && check(s)) k[++num].s=s;
for(i=0;i<=num;i++) cout<<k[i].s<<endl;
by Jared0503 @ 2023-12-11 19:28:20
@DeusExMachina 非常感谢
by Jared0503 @ 2023-12-11 19:41:41
@DeusExMachina 还请大佬再帮忙发现一下问题
#include<bits/stdc++.h>
using namespace std;
struct bin{ //瞎写的结构体,不要笑,功能呢和字符串数组差不多
string s;
}k[110];
bool check(string s)
{
bool re[4]={1,0,0,0};
int len=s.size(),i=0,cnt;
for(;i<len;i++)
{
if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$') continue;
else if(s[i]>='A'&&s[i]<='Z') re[1]=1;
else if(s[i]>='a'&&s[i]<='z') re[2]=1;
else if(s[i]>='0'&&s[i]<='9') re[3]=1;
else re[0]=0;
}
cnt=re[1]+re[2]+re[3];
// cout<<cnt;
return (re[0]==1&&cnt>=2);
}
int main()
{
int i,num=0;
char c;
string s="";
while(cin>>c)
{
if(c==',')
{
// cout<<s;
if(s.size()<=12&&s.size()>=6&&check(s)) k[++num].s=s;
s="";
continue;
}
s+=c;
}
// cout<<s;
if(s.size()<=12&&s.size()>=6&&check(s)) k[++num].s=s;
for(i=1;i<=num;i++) cout<<k[i].s<<endl;
}
第一个数据就WA了
by Jared0503 @ 2023-12-11 19:42:12
@DeusExMachina 测试样例已经过了
by DeusExMachina @ 2023-12-11 20:24:56
@Jared0503 我不想交题 你可以说说怎么 wa 的吗 数据是怎么一回事
by Jared0503 @ 2023-12-11 20:45:34
它不允许我下载数据