HJ20 密码验证合格程序
![在这里插入图片描述](https://img-blog.csdnimg.cn/aa2d222ff9b9408d9b14d89f49939003.png)
#include <iostream>
#include <string>
using namespace std;
string cheak(string &tmp)
{
int flag[4] = {
0,0,0,0};
if(tmp.size() <= 8) return "NG";
for(int i=0 ; i <tmp.size() ; i++)
{
if(tmp[i] >= 'A' && tmp[i] <= 'Z') flag[0] = 1;
else if(tmp[i] >= 'a' && tmp[i] <= 'z') flag[1] = 1;
else if(tmp[i] >= '0' && tmp[i] <= '9') flag[2] = 1;
else flag[3] = 1;
}
int count = 0;
for(int i=0 ; i<4 ; i++)
if(flag[i] == 1) count++;
if(count < 3) return "NG";
for(int i=0 ; i<tmp.size() ; i++)
{
for(int j=i+3 ; j<tmp.size() ; j++)
{
if(tmp[i] == tmp[j] && tmp[i+1] == tmp[j+1] && tmp[i+2] == tmp[j+2])
return "NG";
}
}
return "OK";
}
int main() {
string tmp;
while (cin >> tmp )
{
cout << cheak(tmp) << endl;
}
}