题解 | #密码强度等级#

密码强度等级

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

#include<iostream>
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {
        int len=s.length();
        int minch=0;
        int maxch=0;
        int digit=0;
        int other=0;
        int i=0;
        while(s[i]!='\0')
        {
            if(s[i]>='0'&&s[i]<='9')digit++;
            else if(s[i]>='a'&&s[i]<='z')minch++;
            else if(s[i]>='A'&&s[i]<='Z')maxch++;
            else other++;
            i++;
        }
        int score=0;
        if(len<=4)score+=5;
        else if(len>=5&&len<=7)score+=10;
        else score+=25;
        
        if((minch>0&&maxch==0)||(minch==0&&maxch>0))score+=10;
        else if(minch>0&&maxch>0)score+=20;
        
        if(digit==1)
        {
            score+=10;
        }
        else if(digit>1)
        {
            score+=20;
        }
        if(other==1)
        {
            score+=10;
        }
        else if(other>1)
        {
            score+=25;
        }
        if(minch>0&&maxch>0&&digit>0&&other>0)
        {
            score+=5;
        }
        else if((minch>0||maxch>0)&&digit>0&&other>0)
        {
            score+=3;
        }
        else if(minch>0&&maxch>0&&digit>0&&other==0)
        {
            score+=2;
        }
        string res;
        if(score>=90)res="VERY_SECURE";
        else if(score>=80)res="SECURE";
        else if(score>=70)res="VERY_STRONG";
        else if(score>=60)res="STRONG";
        else if(score>=50)res="AVERAGE";
        else if(score>=25)res="WEAK";
        else if(score>=0)res="VERY_WEAK";
        cout<<res<<endl;
    }
    return 0;
}
全部评论

相关推荐

鲁大牛:第一次美团笔试因为用豆包没做出来。第二次笔试之前重金充了一个gpt5pro的会员。结果第二次不考ai算法题了
投递美团等公司10个岗位
点赞 评论 收藏
分享
珩珺:那些经历都太大太空了,实习的情况不了解,大创项目连名字、背景、目的及意义都没体现出来;地摊经济更是看完连卖的什么产品都不知道,项目成果直接写营收多少都更直观真实一点;后面那个校文体部的更是工作内容是组织活动整理流程,成果变成了当志愿者,而且你们学校本科学生会大一入学就直接当部长吗,志愿里面还提到了疫情防控,全面解封是22年12月的事情,可能时间上也有冲突。可能你花了钱人家就用AI给你随便写了点内容改了一下,没什么体现个性化的点
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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