渣渣炜 @ 2023-12-20 18:49:13
#include<bits/stdc++.h>
using namespace std;
vector<string> word;
void stringToWord(string s){
s=s+',';
for(int i=0,j=0;i<s.length();i++)
if(s[i]==','){
word.push_back(s.substr(j,i-j));
j=i+1;
}
}
bool judge1(string s){
for(int i=0;i<s.length();i++){
if(isdigit(s[i])==false&&isupper(s[i])==false
&&islower(s[i])==false&&s[i]!='!'&&s[i]!='@'&&s[i]!='#'&&s[i]!='$')
return false;
}
return true;
}
bool judge2(string s){
bool flag1=false,flag2=false,flag3=false,flag4=false;
for(int i=0;i<s.length();i++){
if(isdigit(s[i])==true)
flag1=true;
if(islower(s[i])==true)
flag2=true;
if(isupper(s[i])==true)
flag3=true;
if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$')
flag4=true;
}
if(flag4==true)
if(flag1==true&&flag2==true||flag1==true&&flag3==true||flag3==true&&flag2==true)
return true;
return false;
}
int main(){
string s;
cin>>s;
stringToWord(s);
for(int i=0;i<word.size();i++)
if(word[i].length()>=6&&word[i].length()<=12)
if(judge1(word[i])==true&&judge2(word[i])==true)
cout<<word[i]<<endl;
return 0;
}
by derekxue @ 2023-12-23 22:40:49
我测试的时候,用例过不了。
if(isdigit(s[i])==true) flag1=true; if(islower(s[i])==true) flag2=true; if(isupper(s[i])==true) flag3=true;
这几行有问题:
这几个函数返回值不是true和false,是非0和0
by 渣渣炜 @ 2023-12-27 00:56:36
@derekxue 谢谢