题解 | #密码强度等级#

密码强度等级

https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import static java.util.Arrays.*;
import static java.util.stream.Stream.*;


public class Main {
    public static void main(String[] args) throws IOException {

       //testCompletePack();
        testTh();
    }

    private static void testTh() throws IOException {
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        String str;
        while ((str=bf.readLine())!=null){
            int length = str.length();
            int score=0;
            if (length<=4){
                score=score+5;
            }else if (length<=7){
                score=score+10;
            }else {
                score=score+25;
            }
            int flagA=0;
            int flagB=0;
            int flagN=0;
            int flagC=0;
            char[] chars = str.toCharArray();
            for (char aChar : chars) {
                if (aChar>='a'&&aChar<='z'){
                    flagA=1;
                }else if (aChar>='A'&&aChar<='Z'){
                    flagB=1;
                } else if (aChar>='0'&&aChar<='9') {
                    flagN++;
                }else {
                    flagC++;
                }
            }
            if (flagA==1&&flagB==1){
                score=score+20;
            } else if (flagA==1||flagB==1) {
                score=score+10;
            }
            if (flagN==1){
                score=score+10;
            }else if (flagN>1){
                score=score+20;
            }
            if (flagC==1){
                score=score+10;
            } else if (flagC>1) {
                score=score+25;
            }
            if (flagA==1&&flagB==1&&flagN>=1&&flagC>=1){
                score=score+5;
            } else if ((flagA==1||flagB==1)&&flagC>=1&&flagN>=1) {
                score=score+3;
            } else if ((flagA==1||flagB==1)&&flagN>=1) {
                score=score+2;
            }
            if (score>=0&&score<25){
                System.out.println("VERY_WEAK");
            } else if (score<50) {
                System.out.println("WEAK");
            } else if (score<60) {
                System.out.println("AVERAGE");
            } else if (score<70) {
                System.out.println("STRONG");
            } else if (score<80) {
                System.out.println("VERY_STRONG");
            } else if (score<90) {
                System.out.println("SECURE");
            }else {
                System.out.println("VERY_SECURE");
            }
        }

    }




}

全部评论

相关推荐

点赞 评论 收藏
分享
08-14 22:16
门头沟学院 Java
我爱加瓦233:今年行情真的好起来了,暑期实习拿了美团,京东,饿了么三家的Offer,最终去了美团,披上了我的黄马褂,开启送外卖之旅
点赞 评论 收藏
分享
08-14 16:48
门头沟学院 Java
字节我求你别面我了,把我从人才库里捞起来再挂掉。。。我也很受打击,很绝望好嘛
码农索隆:面试官:“这小子讷啊,这小子挂这么多次,我倒要面面,看看怎么个事”
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务