MIAOQINGTIAN @ 2024-06-28 09:53:36
#include <bits/stdc++.h>
using namespace std;
void hg(string s)
{
int flag=0;
if(s.size()>=6 && s.size()<=12)
{
for(char i='A';i<='Z';i++)
{
int n=s.find(i);
if(n!=-1)
{
flag++;
break;
}
}
for(char i='a';i<='z';i++)
{
int n=s.find(i);
if(n!=-1)
{
flag++;
break;
}
}
for(char i='0';i<='9';i++)
{
int n=s.find(i);
if(n!=-1)
{
flag++;
break;
}
}
if(flag>=2)
{
int flag_fh=0;
int n1=s.find('!'),n2=s.find('@'),n3=s.find('#'),n4=s.find('$');
if(n1||n2||n3||n4)
{
flag_fh=1;
}
if(flag_fh==1)
{
string s2=s;
for(int i=0;i<s2.size();i++)
{
if((s[i]<='z' && s[i]>='a') || (s[i]<='Z' && s[i]>='A') || (s[i]>='0' && s[i]<='9') || s[i]=='!' || s[i]=='@' || s[i]=='#' || s[i]=='$')
{
s2.erase(i,1);
}
}
if(s2.size()==0)
{
cout << s << endl;
}
}
}
}
}
int main()
{
string a;
cin >> a;
int dh=0,flag=0;
for(int i=0;i<a.size();i++)
{
if(a[i]==',')
{
string s=a.substr(dh,i-dh);
hg(s);
dh=i+1;
}
}
string s=a.substr(dh,a.size()-dh);
hg(s);
return 0;
}
by fjj54188 @ 2024-06-28 21:08:11
#include<iostream>
using namespace std;
char line[101];
char pwd[101];
bool check(char * str, int l) {
if (l < 6 || l > 12)
return false;
bool hasC = false, hasL = false, hasD = false, hasS = false;
for (int i = 0; str[i] != '\0'; i++) {
if ('A' <= str[i] && str[i] <= 'Z') {
hasC = true;
} else if ('a' <= str[i] && str[i] <= 'z') {
hasL = true;
} else if ('0' <= str[i] && str[i] <= '9') {
hasD = true;
} else if (str[i] == '!' || str[i] == '@' ||str[i] == '#' || str[i] == '$') {
hasS = true;
} else
return false;
}if (!hasS)
return false;
if (hasC + hasL + hasD < 2)
return false;
return true;
}
int main() {
cin >> line;
int len = 0;
for (int i = 0; line[i] != '\0'; i++) {
if (line[i] != ',') {
pwd[len] = line[i];len++;
} else {
pwd[len] = '\0';
if (check(pwd, len))
cout << pwd << endl;len = 0;
}
}if (len > 0) {
pwd[len] = '\0';
if (check(pwd, len))
cout << pwd << endl;
}return 0;
}