密码要求:
1.长度超过8位
2.包括大小写字母.数字.其它符号,以上四种至少三种
3.不能有相同长度超2的子串重复
bool funJGM(string test){
int len = test.length();
int index[4] = { 0 };//0数字,1大写,2小写,3其他符号
if(len>8){
for (int i = 0; i < len; ++i){
if (isalnum(test[i])){ if(index[0]==0)index[0]=1; }
if (islower(test[i])){ if (index[2] == 0)index[2]=1; }
if (isupper(test[i])){ if (index[1] == 0)index[1]=1; }
if (!isalnum(test[i]) && !islower(test[i]) && !isupper(test[i])){ if (index[3] == 0) index[3] = 1; }
}
if (index[0] + index[1] + index[2] + index[3] >= 3){return true; }
else{ return false; }
}
else return false;
}
int funJGMpro(string test){
int len = test.length();
int Maxed = 0,count = 0;
int st1, st2;
for (int i = 0; i < len; ++i){
for (int j = i + 1; j < len; ++j){
st1 = i; st2 = j;
while (test[st1] == test[st2] && st1 < len&&st2 < len)
{
++count; ++st1; ++st2;
}
if (count > Maxed)
Maxed = count;
count = 0;
}
}
return Maxed;
}
void HWoj(){
string test = "021abc900DD";
if (funJGM(test) && (funJGMpro(test) <= 2))cout << "OK\n";
else cout << "NG\n";
}