华为OJ——密码强度等级
来源:互联网 发布:ogame源码 编辑:程序博客网 时间:2024/05/20 06:28
题目描述
密码按如下规则进行计分,并根据不同的得分为密码进行安全等级划分。
一、密码长度:
5 分: 小于等于4 个字符
10 分: 5 到7 字符
25 分: 大于等于8 个字符
二、字母:
0 分: 没有字母
10 分: 全都是小(大)写字母
20 分: 大小写混合字母
三、数字:
0 分: 没有数字
10 分: 1 个数字
20 分: 大于1 个数字
四、符号:
0 分: 没有符号
10 分: 1 个符号
25 分: 大于1 个符号
五、奖励:
2 分: 字母和数字
3 分: 字母、数字和符号
5 分: 大小写字母、数字和符号
最后的评分标准:
>= 90: 非常安全
>= 80: 安全(Secure)
>= 70: 非常强
>= 60: 强(Strong)
>= 50: 一般(Average)
>= 25: 弱(Weak)
>= 0: 非常弱
对应输出为:
VERY_WEAK,
WEAK,
AVERAGE,
STRONG,
VERY_STRONG,
SECURE,
VERY_SECURE
输入描述:
输入一个string的密码
输出描述:
输出密码等级
输入例子:
38$@NoNoNo
输出例子:
VERY_SECURE
import java.util.*;public class Main{public static void main(String[] args) {Scanner scan=new Scanner(System.in);while(scan.hasNext()){String pwd=scan.nextLine();int total=Length(pwd)+Letter(pwd)+number(pwd)+sign(pwd)+reward(pwd);if(total>=90)System.out.println("VERY_SECURE");else if(total>=80)System.out.println("SECURE");else if(total>=70)System.out.println("VERY_STRONG");else if(total>=60)System.out.println("STRONG");else if(total>=50)System.out.println("AVERAGE");else if(total>=25)System.out.println("WEAK");elseSystem.out.println("VERY_WEAK");}}//判断长度static int Length(String str){int score=0;if(str.length()<=4){score+=5;}else if(str.length()>=8){score+=25;}else{score+=10;}return score;}//判断字母static int Letter(String str){int score=0;int xiao=0;int da=0;for(Character ch:str.toCharArray()){if(ch>='a' && ch<='z') xiao=1;else if(ch>='A' && ch<='Z') da=1;}if(xiao==1 && da==1) score=20;else if(xiao==0 && da==0) score=0;else score=10;return score;}//判断数字static int number(String str){int score=0;int count=0;for(Character ch:str.toCharArray()){if(ch>='0' && ch<='9') count++;}if(count==0) score=0;else if(count==1) score=10;else score=20;return score;}//判断符号static int sign(String str){int score=0;int count=0;for(Character ch:str.toCharArray()){if(!(ch>='0' && ch<='9') && !(ch.toLowerCase(ch)>='a' && ch.toLowerCase(ch)<='z')) count++;}if(count==0) score=0;else if(count==1) score=10;else score=25;return score;}//奖励static int reward(String str){int score=0;if(number(str)>0 && Letter(str)==20 && sign(str)>0)score=5;else if(number(str)>0 && Letter(str)>0 && sign(str)>0)score=3;else if(number(str)>0 && Letter(str)>0)score=2;return score;}}
0 0
- 华为OJ——密码强度等级
- 华为OJ——密码强度等级
- 华为OJ——密码强度等级
- 华为OJ-密码强度等级
- 【华为oj】密码强度等级
- 华为oj 密码强度等级
- 华为oj 密码强度等级
- 【华为 OJ 】密码强度等级
- 【华为OJ】密码强度等级
- 华为OJ(密码强度等级)
- 【华为OJ】【086-密码强度等级】
- 华为OJ 初级:密码强度等级
- 华为oj初级 密码强度等级
- OJ-----密码强度等级
- 华为OJ训练之0034-170112-密码强度等级
- 华为机试:密码强度等级、百钱买百鸡问题
- 密码强度等级
- 密码强度等级
- [Codeforces 27D] Ring Road 2 (二分图染色)
- Android异步回调中的UI同步性问题
- 主席树基础介绍
- Android中JNI使用详解(4)---Java与C之间数据类型转换
- codevs 5118 , Wjj的视频2 , 高精度
- 华为OJ——密码强度等级
- JNI原生函数中JNIEnv参数详解
- 编程之美---电梯调度算法
- ML 算法之TF-IDF
- PhpStorm的安装激活与项目创建
- 【POJ 1383 Labyrinth】
- 黄阶中级 - 操作系统 - 导论 - 修改0次
- [原创]Warning: Failed prop type: Invalid prop `enablesReturnKeyAutomatically` of type `string` supplie
- 漫步线性代数八——向量空间和子空间