5网站建设公司,常用的网站制作软件,seo怎么去优化网站,7个免费的ui素材网站目录
牛客HJ87 密码强度等级
解析代码 牛客HJ87 密码强度等级
密码强度等级_牛客题霸_牛客网
题目描述
密码按如下规则进行计分#xff0c;并根据不同的得分为密码进行安全等级划分。 一、密码长度: 5 分: 小于等于4 个字符 10 分: 5 到7 字符 25 分: 大于等于8 个字符 二…目录
牛客HJ87 密码强度等级
解析代码 牛客HJ87 密码强度等级
密码强度等级_牛客题霸_牛客网
题目描述
密码按如下规则进行计分并根据不同的得分为密码进行安全等级划分。 一、密码长度: 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 对应输出为 VERY_SECURE SECURE VERY_STRONG STRONG AVERAGE WEAK VERY_WEAK 请根据输入的密码字符串进行安全评定。 注 字母a-z, A-Z 数字0-9 符号包含如下 (ASCII码表可以在UltraEdit的菜单view-ASCII Table查看) !#$%()*,-./ (ASCII码0x21~0x2F) :;? (ASCII码0x3A~0x40) [\]^_ (ASCII码0x5B~0x60) {|}~ (ASCII码0x7B~0x7E) 提示: 1 字符串的长度 300
输入描述
输入一个string的密码
输出描述
输出密码等级 解析代码
#include cctype
#include iostream
#include string
using namespace std;
int level(string str)
{int ret 0;int n str.size(); // 长度if (n 4)ret 5;else if (n 5 n 7)ret 10;elseret 25;//cout 长度 n 分数 ret endl;int low 0, gre 0, cnt0 0; // 0字母for (auto e : str) {if (islower(e))low;else if (isupper(e))gre;cnt0 low gre;}if (low gre 0)ret 10;else if (gre low 0)ret 10;else if (gre low)ret 20;int cnt1 0; // 1数字for (auto e : str) {if (isdigit(e))cnt1;}if (cnt1 1)ret 10;else if (cnt1 1)ret 20;int cnt2 0; // 2符号for (auto e : str){if (e 0x21 e 0x2F|| e 0x3A e 0x40|| e 0x5B e 0x60|| e 0x7B e 0x7E)cnt2;}if (cnt2 1)ret 10;else if (cnt2 1)ret 25;if (low gre cnt1 cnt2) // 加分ret 5;else if (cnt0 cnt1 cnt2)ret 3;else if (cnt0 cnt1)ret 2;return ret;
}int main()
{string str;cin str;int res level(str);//cout res;if (res 90)cout VERY_SECURE;else if (res 80)cout SECURE;else if (res 70)cout VERY_STRONG;else if (res 60)cout STRONG;else if (res 50)cout AVERAGE;else if (res 25)cout WEAK;elsecout VERY_WEAK;return 0;
}