思路:
按照三种不符的条件去判断
代码:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
while(cin >> s)
{
if(s.length() <= 8){
cout << "NG" << endl;
continue;
}
int a = 0,b = 0,c = 0,d = 0;
for(int i = 0; i < s.length(); i++){
if(s[i] >= 'A' && s[i] <= 'Z') a = 1;
else if(s[i] >= 'a' && s[i] <= 'z') b = 1;
else if(s[i] >= '0' && s[i] <= '9') c = 1;
else d = 1;
}
if(a + b + c + d < 3){
cout << "NG" << endl;
continue;
}
bool flag = false;
for(int i = 0; i + 6 <= s.size(); i++){
for(int j = i + 3; j + 3 <= s.size(); j++)
if(s.substr(i, 3) == s.substr(j, 3)){
flag = true;
break;
}
if(flag) break;
}
if(flag)cout << "NG" << endl;
else cout << "OK" << endl;
}
}
评论区