#include <iostream> #include <string> #include <vector>using namespace std;//computes the kind of character in a string int Caltypekinds (string &str) {int Count[4];memset (count, 0, sizeof (int)); for (size_t i = 0; i < str.length (); ++i) {i F (str[i] >= ' A ' && str[i] <= ' Z ') {count[0]++;} else if (Str[i] >= ' A ' && str[i] <= ' z ') {count[1] + +;} else if (Str[i] >= ' 0 ' && str[i] <= ' 9 ') {count[2] + +;} else{count[3]++;}} int typenum =0;for (int i = 0; I <4; ++i) {if (0! = Count[i]) {typenum + +;}} return typenum;} BOOL Iscontainsamesubstr (String &str) {size_t len = str.length (); for (int i = 0; i < len-2; ++i) {for (int j = i + 1; J < Len-2; ++J) {if (strncmp (& (Str[i]), & (Str[j]), 3) = = 0) {return true;}}} return false;} int main () {string Str;bool flag = False;int Typetotal = 0;while (cin>>str) {flag = False;typetotal =0;//1. Determine if the length exceeds 8// 2. Computes the character type in the string typetotal = Caltypekinds (str);//3. Determines whether the string has the same substring of length greater than 2 bool Sameflag = ISCONTAINSAMESUBSTR (str); if (Str.length () > 8 && typetotal >=3 && Sameflag = False) {cout<< "OK" <<ENDL;} else{cout<< "NG" <<endl;}} return 0;}
Password Verification Qualification Program