TNT_666 @ 2024-08-30 21:27:42
样例过,自己造了也过
#include<bits/stdc++.h>
using namespace std;
char a[105];
int s,d,x,f,b,lena,flg,c;
int main(){
cin>>a;
lena=strlen(a);
for(int i=0;i<=lena;i++){
if(a[i]>='0'&&a[i]<='9')s=1,c++;
else if(a[i]>='a'&&a[i]<='z')x=1,c++;
else if(a[i]>='A'&&a[i]<='Z')d=1,c++;
else if(a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$')f=1,c++;
else if(a[i]==','){
if(c<6||c>12){s=0,d=0,x=0,f=0,b=0,c=0,flg=0;continue;}
if(s&&x||s&&d||x&&d)b=1;
else{s=0,d=0,x=0,f=0,b=0,c=0,flg=0;continue;}
if(b&&f&&flg!=-1){
for(int j=i-c;j<i;j++)cout<<a[j];
cout<<endl;
s=0,d=0,x=0,f=0,b=0,c=0,flg=0;
}
}else if(a[i]=='\0'){
if(c<6||c>12)break;
if(s&&x||s&&d||x&&d||s&&x&&d)b=1;
else break;
if(b&&f&&flg!=-1){
for(int j=i-c;j<i;j++)cout<<a[j];
}
}else flg=-1;
}
return 0;
}
求大佬修改,玄关
by SXY20121009 @ 2024-10-26 19:48:43
#include<bits/stdc++.h>
using namespace std;
string s;
char a[901];
int j=1,es,el,sz,xc;
int main()
{
cin>>s;
for(int i=0; i<=s.size(); i++){
if(s[i]!=','){
a[j] = s[i];
j++;
if(s[i] >= 'a' && s[i] <= 'z'){
es++;
}
if(s[i] >= 'A' && s[i] <= 'Z'){
el++;
}
if(s[i] >= '0' && s[i] <= '9'){
sz++;
}
if(s[i] == '!' || s[i] == '@' || s[i] == '#' || s[i] == '$'){
xc++;
}
}
if(s[i] == ','){
if(j>=7 && j<=13 && (es!=0 && el!=0 || es!=0 && sz!= 0 || el !=0 && sz!=0) && xc>=1 && es+el+sz+xc==j-1) {
for(int k=1; k<j; k++){
cout<<a[k];
}
cout<<endl;
}
j=1;
es=0;
el=0;
sz=0;
xc=0;
memset(a,0,sizeof(a));
}
}
return 0;
}
我这样的