LMR_Minecraft @ 2024-11-09 12:15:00
本人蒟蒻,不喜勿喷
#include<iostream>
#include<string>
using namespace std;
int x[3]={ 0 };
int howlong(string a) {
if (a.size() > 5 && a.size() < 13)return 1;
else return 0;
}
int az1(char a) {
if (int(a) >= 97 && int(a) <= 122)x[0] = 1;
return 0;
}
int az2(char a) {
if (int(a) >= 65 && int(a) <= 90)x[1] = 1;
return 0;
}
int az3(char a) {
if (a=='!'||a=='@'||a=='#'||a=='$')x[2] = 1;
return 0;
}
int az(string a) {
int num = 0;
for (int i = 0; i < 3; i++) {
if (x[i] == 1)num++;
}
if (num >= 2)return 1;
else return 0;
}
int main() {
string a, part[100];
int num = 0, temp = 0;
cin >> a;
for (int i = 0; i <= a.size(); i++) {
if (i == a.size() || a[i] == ',') {
if (num < i) {
part[temp] = a.substr(num, i - num);
temp++;
}
num = i + 1;
}
}
for (int i = 0; i <= temp; i++) {
if (howlong(part[i]) == 1) {
if (az(part[i]) == 1)cout << part[i] << endl;
}
}
return 0;
}
by Xies_X @ 2024-11-09 12:41:34
#include <iostream>
#include <string>
using namespace std;
int x[3]; // 用于标记小写、大写和特殊字符
int howlong(string a) {
return (a.size() >= 6 && a.size() <= 12) ? 1 : 0;
}
void resetX() {
for (int i = 0; i < 3; i++) {
x[i] = 0; // 重置标记数组
}
}
int az1(char a) {
if (a >= 'a' && a <= 'z') x[0] = 1; // 小写字母
return 0;
}
int az2(char a) {
if (a >= 'A' && a <= 'Z') x[1] = 1; // 大写字母
return 0;
}
int az3(char a) {
if (a == '!' || a == '@' || a == '#' || a == '$') x[2] = 1; // 特殊字符
return 0;
}
int az(string a) {
int num = 0;
for (int i = 0; i < 3; i++) {
if (x[i] == 1) num++;
}
return (num >= 2) ? 1 : 0; // 至少两种字符类型
}
int main() {
string a, part[100];
int num = 0, temp = 0;
cin >> a;
// 处理输入字符串,分割成多个密码
for (int i = 0; i < a.size(); i++) {
if (a[i] == ',') {
part[temp++] = a.substr(num, i - num);
num = i + 1;
}
}
part[temp++] = a.substr(num); // 处理最后一个密码
// 检查每个密码的合规性
for (int i = 0; i < temp; i++) {
resetX(); // 重置标记数组
if (howlong(part[i]) == 1) {
for (char c : part[i]) {
az1(c);
az2(c);
az3(c);
}
if (az(part[i]) == 1) {
cout << part[i] << endl; // 输出合规密码
}
}
}
return 0;
}
应该可以
by Xies_X @ 2024-11-09 12:48:08
稍等一下好像还有问题,out和in文件能给一下吗