hsy0824 @ 2024-08-12 05:28:23
#include <bits/stdc++.h>
using namespace std;
bool mima(string s){
if (s.size() < 6 || s.size() > 12){
return false;
}
int dxs = 0, tszf = 0;
for (int i = 0; i <= s.size()-1; i++){
if (!((s[i]>=97&&s[i]<=122)||(s[i]>=65&&s[i]<=90)||(s[i]>=48&&s[i]<=57)||(s[i]=='!')||(s[i]=='@')||(s[i]=='#')||(s[i]=='$'))){
return false;
}
if (s[i]>=97&&s[i]<=122){
dxs++;
}
if (s[i]>=65&&s[i]<=90){
dxs++;
}
if (s[i]>=48&&s[i]<=57){
dxs++;
}
if (s[i]=='!'){
tszf++;
}
if (s[i]=='@'){
tszf++;
}
if (s[i]=='#'){
tszf++;
}
if (s[i]=='$'){
tszf++;
}
}
if (!(dxs>=2&&tszf>=1)){
return false;
}
return true;
}
int main(){
string a,b;
cin >> a;
int tmp = 0;
for (int j = 0; j <= a.size()-1; j++){
if (a[j] != ','){
b[tmp] = a[j];
tmp++;
continue;
}
if (mima(b) == true){
cout << b << endl;
b = '\0';
tmp = 0;
}
}
return 0;
}
by Jack_John_Guzon @ 2024-08-12 09:03:00
你那函数有返回真的时候吗?
by hsy0824 @ 2024-08-13 22:45:22
@Jack_John_Guzon 有的,在函数的最后一行
by Jack_John_Guzon @ 2024-08-14 08:28:19
不是,你带个样例,看它能不能返回真。 @hsy0824