題目描述:
密碼要求:
1.長(zhǎng)度超過8位
2.包括大小寫字母.數(shù)字.其它符號(hào),以上四種至少三種
3.不能有相同長(zhǎng)度超2的子串重復(fù)
輸入描述:
一組或多組長(zhǎng)度超過2的子符串辜羊。每組占一行
輸出描述:
如果符合要求輸出:OK区宇,否則輸出NG
示例1
輸入
021Abc9000
021Abc9Abc1
021ABC9000
021$bc9000
輸出
021Abc9000
021Abc9Abc1
021ABC9000
021$bc9000
參考程序:
#include <iostream>
#include <string>
using namespace std;
int main(){
int a=0,b1=0,b2=0,b3=0,b4=0;
char s;
string str="";
while(cin.get(s)){
if(s=='\n'||s==' '){
if(a>8&&((b1+b2+b3+b4)>=3)){
for(int i = 0; i <= a-6; i++)
for(int j = i+3;j < a;j++)
if(str[i] == str[j] && str[i+1] == str[j+1] &&str[i+2] == str[j+2])
goto NG;
goto OK;
}
NG:
cout<<"NG"<<endl;
goto RE;
OK:
cout<<"OK"<<endl;
RE:
a=0;b1=0;b2=0;b3=0;b4=0;str="";
}
else{
++a;
if(s>='a' && s<='z') b1=1;
else if(s>='A' && s<='Z') b2=1;
else if(s>='0' && s<='9') b3=1;
else b4=1;
str = str+s;
}
}
return 0;
}