题解 | 密码强度等级

密码强度等级

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

#include <iostream>
#include <string>
using namespace std;

int daxie,xiaoxie,fuhao,shuzi;

int main() {
    string s;cin>>s;
    int Score = 0;
    int len = s.size();
    for(auto i:s){
        if('a'<=i&&i<='z') xiaoxie++;
        else if('A'<=i&&i<='Z') daxie++;
        else if('0'<=i&&i<='9') shuzi++;
        else fuhao++;
    }
    // 密码长度
    if(len<=4) Score+=5;
    else if(len<=7) Score+=10;
    else Score+=25;
    //字母
    if(daxie==0&&xiaoxie==0) Score+=0;
    else if(daxie==0||xiaoxie==0) Score+=10;
    else Score+=20;
    // 数字
    if(shuzi==0) Score+=0;
    else if(shuzi==1)Score+=10;
    else Score+=20;
    //符号
    if(fuhao==0) Score+=0;
    else if(fuhao==1)Score+=10;
    else Score+=25;
    // 奖励
    if(daxie&&xiaoxie&&fuhao&&shuzi) Score+=5;
    else if((daxie||xiaoxie)&&shuzi&&fuhao) Score+=3;
    else if((daxie||xiaoxie)&&shuzi) Score+=2;
    
    if(Score<25) cout<<"VERY_WEAK";
    else if(Score<50) cout<<"WEAK";
    else if(Score<60) cout<<"AVERAGE";
    else if(Score<70) cout<<"STRONG";
    else if(Score<80) cout<<"VERY_STRONG";
    else if(Score<90) cout<<"SECURE";
    else cout<<"VERY_SECURE";


    
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

秋招投简历提醒助手:个人经验是,一般面二十场左右就会进入侃侃而谈阶段。我今年七月末的时候开始的第一次面试,都是很多不会,回复很慢。后面慢慢迭代,到九月中的时候基本上面啥说啥,很放松的状态
远程面试的尴尬瞬间
点赞 评论 收藏
分享
12-11 14:24
门头沟学院 Java
牛客35720396...:不要用boss,全是骗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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