社区讨论
90分求调 调好关
B3843[GESP202306 三级] 密码合规参与者 3已保存回复 4
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @mhj95plh
- 此快照首次捕获于
- 2025/11/03 22:45 4 个月前
- 此快照最后确认于
- 2025/11/03 22:45 4 个月前
CPP
#include <bits/stdc++.h>
using namespace std;
bool check(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 (isupper(s[i])) a ++;
else if (islower(s[i])) b ++;
else if (isdigit(s[i])) c ++;
else if (s[i] == '!' || s[i] == '@' || s[i] == '#' || s[i] == '$') d ++;
else return false;
}
int cnt = 0;
if (a > 0) cnt ++;
if (b > 0) cnt ++;
if (c > 0) cnt ++;
if (cnt >= 2 && d > 0) return true;
else return false;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
string s;
cin >> s;
s += ',';
int n = 0;
for (int i = 0; i < s.size(); i ++)
{
if (s[i] == ',') n ++;
}
for (int i = 1; i <= n; i ++)
{
int w = s.find(',', i);
string g = s.substr(0, w);
s.erase(0, w + 1);
if (check(g)) cout << g << '\n';
}
return 0;
}
回复
共 4 条回复,欢迎继续交流。
正在加载回复...