Title Description
Password Requirements:
1. More than 8 bits in length
2. Include uppercase and lowercase letters. Numbers, other symbols, above four species at least three kinds
3. Can not have the same length of over 2 substring repetition
Enter a description
One or more sets of substrings that are longer than 2. Each group takes up one row
Output description
If required output: OK, otherwise output ng
Input example
021abc9000021abc9abc1021abc9000 021$BC 9000
Output example
Okngngok
Test code
1 ImportJava.util.Scanner;2 3 Public classMain {4 //more than 8 bits in length5 Public Static Booleanchecklength (String password) {6 if(Password.equals (NULL) || Password.length () <= 8){7 return false;8 }9 return true;Ten } One //include uppercase and lowercase letters. Numbers, other symbols, above four species at least three A Public Static Booleancheckcharkinds (String password) { - intUppercase = 0, lowercase = 0, digit = 0, other = 0; - Char[] ch =Password.tochararray (); the for(inti = 0; I < password.length (); i++) { - if(Character.isuppercase (Ch[i])) { -Uppercase = 1; -}Else if(Character.islowercase (Ch[i])) { +lowercase = 1; -}Else if(Character.isdigit (Ch[i])) { +digit = 1; A}Else { atother = 1; - } - } - if(uppercase + lowercase + digit + other >= 3) { - return true; - } in return false; - } to //cannot have substring repetition of the same length of over 2 + Public Static Booleancheckcharrepeat (String password) { - for(inti = 0; I < Password.length ()-2; i++) { theString str = password.substring (i, i + 3); * for(intj = i + 1; J < Password.length ()-2; J + +) { $ if(Password.substring (J). Contains (str)) {Panax Notoginseng return false; - } the } + } A return true; the } + - Public Static voidMain (string[] args) { $Scanner sc =NewScanner (system.in); $ while(Sc.hasnextline ()) { -String Password =sc.nextline (); - if(Checklength (password) && checkcharkinds (password) &&checkcharrepeat (password)) { theSystem.out.println ("OK"); -}Else {WuyiSystem.out.println ("NG"); the } - } Wu sc.close (); - } About}
Password Verification Qualification Program