72728abcd @ 2024-06-28 22:30:31
一位准备来考三级的人做的
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t=0,k=0,h;
string a;
string b[105]={};
string c[105]={};
cin>>a;
char g=getchar();
for(int i=0;i<105;i++)
{
if(g==',')
{
h=t;
t=i;
for(int j=h;j<t;j++)
{
b[k]+=a[j];
}
k++;
}
for(int j=h;j<t;j++)
{
b[k]+=a[j];
}
}
for(int i=0;i<k;i++)
{
if((b[i].find("!")!=string::npos||b[i].find("@")!=string::npos||b[i].find("#")!=string::npos||b[i].find("$")!=string::npos)&&(b[i].length()>=6||b[i].length()<=12)&&((b[i].find("a")!=string::npos||b[i].find("b")!=string::npos||b[i].find("c")!=string::npos||b[i].find("d")!=string::npos||b[i].find("e")!=string::npos||b[i].find("f")!=string::npos||b[i].find("g")!=string::npos||b[i].find("h")!=string::npos||b[i].find("i")!=string::npos||b[i].find("j")!=string::npos||b[i].find("k")!=string::npos||b[i].find("l")!=string::npos||b[i].find("m")!=string::npos||b[i].find("n")!=string::npos||b[i].find("o")!=string::npos||b[i].find("p")!=string::npos||b[i].find("q")!=string::npos||b[i].find("r")!=string::npos||b[i].find("s")!=string::npos||b[i].find("t")!=string::npos||b[i].find("u")!=string::npos||b[i].find("v")!=string::npos||b[i].find("w")!=string::npos||b[i].find("x")!=string::npos||b[i].find("y")!=string::npos||b[i].find("z")!=string::npos)+(b[i].find("A")!=string::npos||b[i].find("B")!=string::npos||b[i].find("C")!=string::npos||b[i].find("D")!=string::npos||b[i].find("E")!=string::npos||b[i].find("F")!=string::npos||b[i].find("G")!=string::npos||b[i].find("H")!=string::npos||b[i].find("I")!=string::npos||b[i].find("J")!=string::npos||b[i].find("K")!=string::npos||b[i].find("L")!=string::npos||b[i].find("M")!=string::npos||b[i].find("N")!=string::npos||b[i].find("O")!=string::npos||b[i].find("P")!=string::npos||b[i].find("Q")!=string::npos||b[i].find("R")!=string::npos||b[i].find("S")!=string::npos||b[i].find("T")!=string::npos||b[i].find("U")!=string::npos||b[i].find("V")!=string::npos||b[i].find("W")!=string::npos||b[i].find("X")!=string::npos||b[i].find("Y")!=string::npos||b[i].find("Z")!=string::npos)+(b[i].find("0")!=string::npos||b[i].find("1")!=string::npos||b[i].find("2")!=string::npos||b[i].find("3")!=string::npos||b[i].find("4")!=string::npos||b[i].find("5")!=string::npos||b[i].find("6")!=string::npos||b[i].find("7")!=string::npos||b[i].find("8")!=string::npos||b[i].find("9")!=string::npos)>=2)&&(b[i].find("~")==string::npos||b[i].find("`")==string::npos||b[i].find("%")==string::npos||b[i].find("^")==string::npos||b[i].find("&")==string::npos||b[i].find("*")==string::npos||b[i].find("(")==string::npos||b[i].find(")")==string::npos||b[i].find("_")==string::npos||b[i].find("-")==string::npos||b[i].find("+")==string::npos||b[i].find("=")==string::npos||b[i].find("{")==string::npos||b[i].find("}")==string::npos||b[i].find("|")==string::npos||b[i].find(";")==string::npos||b[i].find(":")==string::npos||b[i].find("'")==string::npos||b[i].find(",")==string::npos||b[i].find("<")==string::npos||b[i].find(".")==string::npos||b[i].find(">")==string::npos||b[i].find("?")==string::npos||b[i].find("/")==string::npos))
{
cout<<b[i]<<endl;
}
}
return 0;
}
0分,我不知道怎么调/简化,求助!
by ___define___ @ 2024-06-28 22:46:23
@72728abcd 把后面判断的||
改成&&
?
by ___define___ @ 2024-06-28 22:49:22
@72728abcd 说实话,你大可不必这么多判断
by Derek123wzy @ 2024-06-29 14:28:23
AC代码赠与你:
#include<bits/stdc++.h>
using namespace std;
string s,res[101],tmp;
int num;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>s;
for(int i=0;s[i];i++)
if(s[i]==',')res[num++]=tmp,tmp="";
else tmp+=s[i];
for(int i=0;i<num;i++)
if(res[i].size()>5&&res[i].size()<13){
bool f=true;
int cntd=0,cntx=0,cnts=0,cntt=0,cnt=0;
for(int j=0;res[i][j];j++)
if((res[i][j]<'A'||res[i][j]>'Z')&&(res[i][j]<'a'||res[i][j]>'z')&&(res[i][j]<'0'
||res[i][j]>'9')&&res[i][j]!='!'&&res[i][j]!='@'&&res[i][j]!='#'&&res[i][j]!='$'){
f=false;
break;
}else if(res[i][j]>='0'&&res[i][j]<='9')cnts++;
else if(res[i][j]>='a'&&res[i][j]<='z')cntx++;
else if(res[i][j]>='A'&&res[i][j]<='Z')cntd++;
else cntt++;
if(cntd)cnt++;
if(cntx)cnt++;
if(cnts)cnt++;
if(!f||cnt<2||!cntt)continue;
cout<<res[i]<<'\n';
}
return 0;
}
by 72728abcd @ 2024-06-29 14:32:17
@Derek123wzy 谢谢Thanks♪(・ω・)ノ
by Derek123wzy @ 2024-07-23 09:27:01
没关系