lizicl @ 2024-10-10 20:52:27
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
getline(cin,s);
char a[105][105];
int x=0,y=0;
bool ds=0,xs=0,sz=0,ts=0;
for(int i=0;i<s.size();i++){
if(s[i]!=','){
a[x][y]=s[i];
y++;
}
if(s[i]==','){
x++;
y=0;
}
}
for(int i=0;i<x;i++){
if(strlen(a[i])>=6&&strlen(a[i])<=12){
for(int j=0;j<strlen(a[i]);j++){
if('a'>=a[i][j]&&'z'<=a[i][j]){
xs=1;
}
if('A'>=a[i][j]&&'Z'<=a[i][j]){
ds=1;
}
if('0'>=a[i][j]&&'9'<=a[i][j]){
sz=1;
}
if(a[i][j]=='!'||a[i][j]=='@'||a[i][j]=='#'||a[i][j]=='$'){
ts=1;
}
}
xs=0;ds=0;sz=0;ts=0;
if(xs+ds+sz>=2&&ts==1){
cout<<a[i]<<endl;
}
}
}
return 0;
}
为什么会错捏
by luochenyv @ 2024-10-11 19:05:32
#include<bits/stdc++.h>
using namespace std;
string s,t;
bool str(string s){
if(s.size()<6||s.size()>12) return false;
int a=0,b=0,c=0,d=0;
for(int i=0;i<s.size();i++){
if(s[i]>='0'&&s[i]<='9') a=1;
else if(s[i]>='a'&&s[i]<='z') b=1;
else if(s[i]>='A'&&s[i]<='Z') c=1;
else if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$') d=1;
else return false;
}
if(a+b+c>=2&&d==1) return true;
return false;
}
int main(){
cin>>s;
for(int i=0;i<s.size();i++){
if(s[i]==','){
if(str(t))cout<<t<<endl;
t="";
}
else t+=s[i];
}
if(str(t)) cout<<t;
return 0;
}
AC代码,求关