题解 | #密码强度等级#

密码强度等级

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

#include<stdio.h>
#include<string.h>
int main(){
    char str[301]={'\0'};
    int score1=0,score2=0,score3=0,score4=0,score5=0;
    int len=0,nw=0,nW=0,nd=0,ns=0;
    scanf("%[^\n]",str);
    //提取数量
    for(int i=0;i<strlen(str);i++){
        if(str[i]>='a'&&str[i]<='z')
            nw++;
        else if(str[i]>='A'&&str[i]<='Z')
            nW++;
        else if(str[i]>='0'&&str[i]<='9')
            nd++;
    }
    len=strlen(str);
    ns=len-nw-nW-nd;
    //1.密码长度
    if(len<=4)
        score1=5;
    else if(len>=5&&len<=7)
        score1=10;
    else score1=25;
    //2.字母
    if(nw==0&&nW==0)
        score2=0;
    else if(nw==0||nW==0)
        score2=10;
    else if(nw!=0&&nW!=0)
        score2=20;
    //3.数字
    if(nd==0)
        score3=0;
    else if(nd==1)
        score3=10;
    else score3=20;
    //4.符号
    if(ns==0)
        score4=0;
    else if(ns==1)
        score4=10;
    else score4=25;
    //5.奖励
    if(nw*nW*nd*ns!=0)
        score5=5;
    else if(nw*nd*ns!=0||nW*nd*ns!=0)
        score5=3;
    else if(nw*nd!=0||nW*nd!=0)
        score5=2;
    //总计
    int total;
    total=score1+score2+score3+score4+score5;
    switch(total/10){
        case 9:printf("VERY_SECURE");break;
        case 8:printf("SECURE");break;
        case 7:printf("VERY_STRONG");break;
        case 6:printf("STRONG");break;
        case 5:printf("AVERAGE");break;
    }
    if(total>=25&&total<50)
        printf("WEAK");
    else if(total>=0&&total<25)
        printf("VERY_WEAK");
}
全部评论

相关推荐

10-29 22:30
吉林大学 Java
同专业学长学姐,去互联网大厂的起薪&nbsp;15k+,去国企&nbsp;IT&nbsp;岗的也有&nbsp;12k+,就连去中小厂的都基本&nbsp;13k&nbsp;起步😤&nbsp;我投的传统行业技术岗,拼死拼活拿到&nbsp;1Woffer,本来还挺开心,结果逛了圈牛客直接破防,同是校招生,行业差距怎么就这么大啊!
喵喵喵6_6:应该哪里不对吧,大厂都是20k以上的,10k那种对于985本的学生基本就是点击一下过了笔试就送的,我前两天刚拿了一个11k,笔试完第2天就打电话了,非科班。坏消息是c++岗开这么低真是刷新认知了
校招生月薪1W算什么水平
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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