题解 | #密码强度等级#

密码强度等级

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");
            }
        }

    }




}

全部评论

相关推荐

程序员小白条:找的太晚,别人都是大三实习,然后大四秋招春招的,你大四下了才去实习,晚1年
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-03 18:22
投了几百份简历,专业和方向完全对口,都已读不回。尝试改了一下学校,果然有奇效。
steelhead:这不是很正常嘛,BOSS好的是即便是你学院本可能都会和聊几句,牛客上学院本机会很少了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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