liruizhou_lihui @ 2023-10-18 21:15:20
#include<bits/stdc++.h>
using namespace std;
string s,s1;
int a[105];
int main()
{
cin>>s;
a[0]=-1;
int z=1;
for(int i=0;i<s.size();i++)
{
bool f1=0,f2=0,f3=0;
if(s[i]==',')
{
a[z]=i;
z++;
}
s1=s.substr(a[i]+1,a[i+1]-a[i]-1);
cout<<s1<<' ';
for(int j=0;i<s1.size();i++)
{
if((s1[j]>='a' && s1[i]<='z') || (s1[i]>='0' && s1[i]<='9'))f1=1;
else if(s1[i]>='A'&& s1[i]<='Z')f2=1;
else if(s1[i]=='!' || s1[i]=='@' || s1[i]=='#' || s1[i]=='$')f3=1;
}
if(f1+f2+f3>=2)
{
cout<<s1<<endl;
}
}
}
by lao_wang @ 2023-10-18 21:16:06
#include<bits/stdc++.h>
using namespace std ;
string s , temp ;
int main() {
cin >> s ;
for(int i=0;i<s.size();i++){
if(s[i]==','){
int a=0 , b=0 , c=0 , d=0 , sum=0 ;
for(int j=0;j<temp.size();j++){
if(temp[j]>='0'&&temp[j]<='9'){
a++ ;
}else if(temp[j]>='a'&&temp[j]<='z'){
b++ ;
}else if(temp[j]>='A'&&temp[j]<='Z'){
c++ ;
}else if(temp[j]=='$'||temp[j]=='@'||temp[j]=='#'||temp[j]=='!'){
d++ ;
}
}
if(a) sum++ ;
if(b) sum++ ;
if(c) sum++ ;
if(sum>=2&&d&&temp.size()<=12&&temp.size()>=6) cout << temp << endl ;
temp.clear() ;
}else{
temp += s[i] ;
}
}
return 0 ;
}
by xtempy @ 2023-10-29 23:05:42
#include<iostream>
using namespace std;
int main() {
int g1,g2,g3,g4,g5,l,r; // 对应四种字符的标志/次数 ,g5是非合法字符
char ch;
string str;
cin>>str;
str=str+',';
g1=0;g2=0;g3=0;g4=0;g5=0;l=0;
for (int i=0; i<str.size(); ) {
ch=str[i];
if (ch>='a' && ch<='z') g1=1;
else if (ch>='A' && ch<='Z') g2=1;
else if (ch>='0' && ch<='9') g3=1;
else if (ch=='!' || ch=='@' || ch=='#' || ch=='$') g4=1;
else if (ch==',') {
r=i;
if (r-l>=6 && r-l<=12 && g1+g2+g3>=2 && g4==1 && g5==0){
cout<<str.substr(l,r-l)<<endl;
}
g1=0;g2=0;g3=0;g4=0;g5=0; i++;
l=i;
continue;
}
else g5=1;
i++;
}
}
by Bei_Gua_ @ 2023-11-11 14:15:55
本蒟蒻的code:
#include<bits/stdc++.h>
#define int long long
using namespace std;
string source;
bool check(string s){
if (s.length()<6||s.length()>12)return false;
int k=0;
bool f1=false,f2=false,f3=false,f4=false;
for (auto c:s){
if (!(('a'<=c&&c<='z')||('A'<=c&&c<='Z')||('0'<=c&&c<='9')||c=='!'||c=='@'||c=='#'||c=='$')){
return false;
}
if ('a'<=c&&c<='z'&&!f1)f1=true,k++;
if ('A'<=c&&c<='Z'&&!f2)f2=true,k++;
if ('0'<=c&&c<='9'&&!f3)f3=true,k++;
if ((c=='!'||c=='@'||c=='#'||c=='$')&&!f4)f4=true;
}
if (k>=2&&f4)return true;
else return false;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>source;
string str;
for (int i=0;i<(int)source.length();i++){
char c=source[i];
if (c==','){
if (check(str))cout<<str<<"\n";
str="";
}else str+=c;
}
}