#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool isvalid(string& s) {
int valid = 0;
int len = s.size();
if (len < 8) return false;
int digit = 1;
int a = 1;
int A = 1;
int etc = 1;
for (int i = 0; i < len; i++) {
if (s[i] >= '0' && s[i] <= '9') {
if (digit) {
valid++;
digit = 0;
}
}
else if (s[i] >= 'a' && s[i] <= 'z') {
if (a) {
valid++;
a = 0;
}
}
else if (s[i] >= 'A' && s[i] <= 'Z') {
if (A) {
valid++;
A = 0;
}
}
else {
valid++;
}
}
if (valid >= 4) return true;
return false;
}
int main() {
string s;
vector<string>arr;
while (getline(cin, s)) {
arr.push_back(s);
}
for (int i = 0; i < arr.size(); i++) {
bool res = isvalid(arr[i]);
if (res) cout << "OK" << endl;
else cout << "Irregular password" << endl;
}
return 0;
}
不知道为什么赛码网显示“未通过所有测试案例”,好歹过一点吧,不知道什么问题
全部评论
(4) 回帖