经典指数          
原因
2560
浏览数
0
收藏数
 

密码要求:   1.长度超过8位   2.包括大小写字母.数字.其它符号,以上四种至少三种   3.不能有相同长度超2的子串重复   说明:长度超过2的子串 输入描述: 一组或多组长度超过2的子符串。每组占一行 输出描述: 如果符合要求输出:OK,否则输出NG 输入例子: 021Abc9000 021Abc9Abc1 021ABC9000 021$bc9000 输出例子: OK NG NG OK

     举报   纠错  
 
切换
1 个答案
#include #include using namespace std; int main(){ string str; while(cin >> str){ int flag[4] = {0}; if(str.size() <= 8) goto NG; for(int i = 0; i < str.size(); ++i) if(str[i] >= 'a' && str[i] <= 'z') flag[0] = 1; else if(str[i] >= 'A' && str[i] <= 'Z') flag[1] = 1; else if(str[i] >= '0' && str[i] <= '9') flag[2] = 1; else flag[3] = 1; if(flag[0] + flag[1] + flag[2] + flag[3] < 3) goto NG; for(int i = 0; i <= str.size()-6; i++) for(int j = i+3;j < str.size();j++) if(str[i] == str[j] && str[i+1] == str[j+1] &&str[i+2] == str[j+2]) goto NG; OK: cout << "OK" << endl;continue; NG: cout << "NG" << endl; } return 0; }//我的是最短的吗?
 
切换
撰写答案
扫描后移动端查看本题