题解 | #密码强度等级#

密码强度等级

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

#include<stdio.h>
#include<ctype.h>
int main(){
    char str[301];
    while(~scanf("%s",str)){
        int len=0,low=0,up=0,d=0,simbol=0;
        while(str[len]){
            if(islower(str[len]))low++;
            else if(isupper(str[len]))up++;
            else if(isdigit(str[len]))d++;
            else simbol++;
            len++;
        }
        int score=0;
        score+=len<5?5:len<8?10:25;
        score+=up&&low?20:!up&&!low?0:10;
        score+=d<2?d*10:20;
        score+=simbol<2?simbol*10:25;
        score+=up&&low&&d&&simbol?5:
                (up||low)&&d&&simbol?3:
                 (up||low)&&d?2:0;
        if(score>=90)printf("VERY_SECURE\n");
        else if(score>=80)printf("SECURE\n");
        else if(score>=70)printf("VERY_STRONG\n");
        else if(score>=60)printf("STRONG\n");
        else if(score>=50)printf("AVERAGE\n");
        else if(score>=25)printf("WEAK\n");
        else printf("VERY_WEAK\n");
    }
}
全部评论

相关推荐

02-04 17:01
南昌大学 Java
牛客96763241...:拿插件直接投就完了,这玩意看运气的
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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