题解 | #密码验证合格程序#

密码验证合格程序

https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841

#include <iostream>
#include <algorithm>
#include<numeric>//accumulate函数在这个库中定义

using namespace std;

string mimayanzheng(string str){
    int arr[4] ={0};
    int num = 0;
    int len = str.size();
    for(int i=0;i<len;i++){
        if(isupper(str[i])){
            arr[0] = 1;
        }else if(islower(str[i])){
            arr[1] = 1;
        }else if(isdigit(str[i])){
            arr[2] = 1;
        }else{
            arr[3] = 1;
        }
    }
    int again = 0;
    for(int i = 0;i<=len-6;i++){  //虽然是len-6 但是i在下面还是可以取到len-5 len -4
        for(int j = i+3;j<len;j++){
            if(str.substr(i,3)==str.substr(j,3)){
                again++;
            } 
        }
        
    }
    if((str.size()>8)&&(again==0)&&(accumulate(arr,arr+4,0)>2)){
        return "OK";
    }else{
        return "NG";
    }
    return 0;
}


int main(){
    string str;
    while(getline(cin,str)){
        cout<<mimayanzheng(str)<<endl;
    }
    return 0;
}

全部评论

相关推荐

虽然大家都在劝退读研,说读研以后也是打工,不如本科直接去打工,但随着现在研究生越来越多,很多企业招聘要求就会变成研究生起招,本科投递简历就会被卡,横向比较时也会因为"本科学历比不上研究生学历"被筛掉,而且你没发现劝退读研的基本都是读完研的人吗?而且进体制、国企等,研究生也比本科生升的快,他们拿着研究生文凭劝你一个本科生,可别当真了
球1个offer:每个行业都是不一定的,例如计算机开发岗,只要是92学历,完全可以冲互联网大厂,没进去抛开运气因素,就是不够努力,准备的晚没有实习等等。计算机算法岗还是要读研的,研究生是基本要求。现在太多人无脑考研了,因为本科秋招春招啥都没准备过,只能读研
点赞 评论 收藏
分享
Twilight_mu:经典我朋友XXXX起手,这是那种经典的不知道目前行情搁那儿胡编乱造瞎指导的中年人,不用理这种**
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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