Urbosa @ 2024-08-29 11:31:36
tell me why?!
代码:
#include <bits/stdc++.h>
using namespace std;
long long cnt;
int main() {
string s;
cin>>s;
for(long long i=0;i<s.length();i++){
cnt++;
if(cnt>=6&&cnt<=12&&s[i]==','){
for(long long k=1;k<cnt;k++){
if((s[k]>='a'&&s[k]<='z')||(s[k]>='A'&&s[k]<='Z')||(s[k]>='0'&&s[k]<='9')){
for(long long j=1;j<cnt;j++){
if(s[k]=='!'||s[k]=='@'||s[k]=='#'||s[k]=='$'){
for(long long g=1;g<cnt;g++){
cout<<s[g];
}
}
}
cout<<endl;
}
}
cnt=0;
}
}
return 0;
}
by lucasincyber @ 2024-08-29 12:46:26
@Urbosa 应该记录当前的密码,再去判断是否合法,最后再输出。
by lucasincyber @ 2024-08-29 12:49:17
这样判断合法有问题,对于每一个字符,只要是 'A'~'Z'或'a'~'z'或'0'~'9'或那四个特殊字符才合法,必须全都合法才可以。
by Urbosa @ 2024-08-29 13:09:29
@lucasincyber
还是不行啊
#include <bits/stdc++.h>
using namespace std;
long long cnt;
int main() {
string s;
cin>>s;
for(long long i=0;i<s.length();i++){
cnt++;
if(cnt>=6&&cnt<=12&&s[i]==','){
for(long long k=1;k<cnt;k++){
if((s[k]>='a'&&s[k]<='z')||(s[k]>='A'&&s[k]<='Z')||(s[k]>='0'&&s[k]<='9')){
for(long long j=1;j<cnt;j++){
if(s[k]=='!'||s[k]=='@'||s[k]=='#'||s[k]=='$'){
for(long long g=1;g<cnt;g++){
cout<<s[g];
}
}
}
cout<<endl;
}
if(s[k]!=((s[k]>='a'&&s[k]<='z')||(s[k]>='A'&&s[k]<='Z')||(s[k]>='0'&&s[k]<='9'))){
break;
}
}
cnt=0;
}
}
return 0;
}
by lucasincyber @ 2024-08-29 13:11:30
@Urbosa 可以先把每一个密码存下来,再判断
by Urbosa @ 2024-08-29 13:19:55
@lucasincyber 怎么弄啊,大神求求给个代码参照一下
by lucasincyber @ 2024-08-29 13:20:47
#include <bits/stdc++.h>
using namespace std;
const int N = 210;
int cur;
string s;
string str[N];
bool check(char c)
{
if (c == '!' || c == '@' || c == '#' || c == '$') return true;
if (c >= '0' && c <= '9') return true;
if (c >= 'A' && c <= 'Z') return true;
if (c >= 'a' && c <= 'z') return true;
return false;
}
int main()
{
cin >> s;
string tmp = "";
for (int i = 0; i < s.size(); i++)
{
if (s[i] != ',') tmp += s[i];
else
{
str[++cur] = tmp;
tmp = "";
}
}
for (int i = 1; i <= cur; i++)
{
map<char, int> mp;
string tmp = str[i];
if (tmp.size() < 6 || tmp.size() > 12) continue;
bool flag = false;
for (int j = 0; j < tmp.size(); j++)
{
if (!check(tmp[j]))
{
flag = true;
break;
}
mp[tmp[j]]++;
}
if (flag) continue;
int cnt1 = 0, cnt2 = 0;
for (auto j : mp)
{
if (j.first == '!' || j.first == '@' || j.first == '#' || j.first == '$')
{
cnt1++;
continue;
}
if (j.second) cnt2++;
}
if (cnt2 < 2 || !cnt1) continue;
cout << str[i] << endl;
}
return 0;
}
@Urbosa
by lucasincyber @ 2024-08-29 13:22:01
求关
by Urbosa @ 2024-08-29 14:34:09
@lucasincyber 感谢大神,已关!