BH9570 @ 2024-11-17 08:29:38
提交记录
代码:
#include<bits/stdc++.h>
using namespace std;
int main () {
string s;
cin >> s;
string t = "";
for (int i = 0; i < s.size(); i++) {
if (s[i] != ',') {
t.push_back(s[i]);
continue;
}
bool b = 0;
int c1 = 0,c2 = 0,c3 = 0;
bool flag = 0;
for (int j = 0; j < t.size(); j++) {
if (t[j] >= 'a' && t[j] <= 'z') {
c1 = 1;
}
else if (t[j] >= 'A' && t[j] <= 'Z') {
c2 = 1;
}
else if (t[j] >= '0' && t[j] <= '9') {
c3 = 1;
}
else if (t[j] == '!'|| t[j] == '@' || t[j] == '#' || t[j] == '$') {
b = 1;
}
else {
flag = 1;
break;
}
}
if (flag == 0 && c1 + c2 == 2 && c2 + c3 == 2 && c1 + c3 == 2 && b == 1 && t.size() <= 12 && t.size() >= 6) {
cout << t << endl;
}
t = "";
}
return 0;
}
by Florrer_A @ 2024-11-17 08:42:25
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
char c;
string s="";
while(cin>>c)
{
if(c!=',')
{
s+=c;
continue;
}
if(s.size()>=6&&s.size()<=12)
{
int upper=0,lower=0,digit=0,_=0;
for(int i=0;i<s.size();i++)
{
upper=max(upper,int(bool(isupper(s[i]))));
lower=max(lower,int(bool(islower(s[i]))));
digit=max(digit,int(bool(isdigit(s[i]))));
if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$')
{
_=1;
}
if(upper+lower+digit>=2&&_)
{
cout<<s<<"\n";
s="";
break;
}
}
}
s="";
}
return 0;
}
by shanxiwen @ 2024-11-17 08:43:30
@BH9570
first,输入最后没有逗号,所以最后一个密码你没有检测。
second,
大写字母,小写字母和数字必须至少有其中两种,以及至少有四个特殊字符中的一个。
但是你判断条件写的是'&&'。
经过上述修改:
#include<bits/stdc++.h>
using namespace std;
int main () {
string s;
cin >> s;
s.push_back(',');
string t = "";
for (int i = 0; i < s.size(); i++) {
if (s[i] != ',') {
t.push_back(s[i]);
continue;
}
bool b = 0;
int c1 = 0,c2 = 0,c3 = 0;
bool flag = 0;
for (int j = 0; j < t.size(); j++) {
if (t[j] >= 'a' && t[j] <= 'z') {
c1 = 1;
}
else if (t[j] >= 'A' && t[j] <= 'Z') {
c2 = 1;
}
else if (t[j] >= '0' && t[j] <= '9') {
c3 = 1;
}
else if (t[j] == '!'|| t[j] == '@' || t[j] == '#' || t[j] == '$') {
b = 1;
}
else {
flag = 1;
break;
}
}
if (flag == 0 && (c1 + c2 == 2 || c2 + c3 == 2 || c1 + c3 == 2) && b == 1 && t.size() <= 12 && t.size() >= 6) {
cout << t << endl;
}
t = "";
}
return 0;
}
by shanxiwen @ 2024-11-17 08:45:07
求关
by BH9570 @ 2024-11-17 09:01:17
谢谢,已关!@Florrer_A @shanxiwen
by shaoxiaohang @ 2024-11-23 17:54:53
@Florrer_A大神,我看不懂
by BH9570 @ 2024-11-24 19:19:41
我赞成@shaoxiaohang ,像什么“cin.tie(0)”都没听过