Password Verification Qualification Program

Source: Internet
Author: User

#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" &LT;&LT;ENDL;} else{cout<< "NG" <<endl;}} return 0;}

Password Verification Qualification Program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.