Masked_fool @ 2024-04-05 16:04:27
#include<bits/stdc++.h>
using namespace std;
bool checkc(char c){
if(c>='a' and c<='z') return true;
if(c>='A' and c<='Z') return true;
if(c>='0' and c<='9') return true;
if(c=='!' or c=='@' or c=='#' or c=='$') return true;
}
bool checks(string s){
int l=s.length();
if(l<6 or l>12) return false;
for(int i=0;i<l;i++) if(checkc(s[i])==false) return false;
return true;
}
int main(){
string lin="";bool p=true;char c;
while(cin>>c){
if(c==','){
if(checks(lin)==true) cout<<lin<<endl;
lin="";
continue;
}
else lin+=c;
}
return 0;
}
by xjy574 @ 2024-04-15 20:17:02
应该是因为第三条规则
#include<iostream>
#include<string>
using namespace std;
bool checkc(char c){
if(c>='a' && c<='z')
return true;
if(c>='A' && c<='Z')
return true;
if(c>='0' && c<='9')
return true;
if(c=='!' || c=='@' || c=='#' || c=='$')
return true;
return false;
}
bool checks(string s){
int l=s.length();
int sum1=0,sum2=0,sum3=0,sum4=0;
if(l<6||l>12)
return false;
for(int i=0;i<l;i++){
if(checkc(s[i])==false)
return false;
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(sum1+sum2+sum3>=2&&sum4==1)
return true;
else
return false;
}
int main(){
string s="";
char c;
while(cin>>c){
if(c==','){
if(checks(s)==true)
cout<<s<<endl;
s="";
continue;
}
else s+=c;
}
return 0;
}
by Masked_fool @ 2024-07-26 12:39:18
@xjy574 过了,谢谢大佬