网易2019游戏研发工程师笔试题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jirryzhang/article/details/81559984

第一题:计算个人所得税

#include <iostream>
using namespace std;
int main(){
    int t,n,result;
    float tmp;
    const float g=0.5000001;
    while(cin>>t){
        for(auto i=0;i<t;++i){
            cin>>n;
            if(n<=5000) {
                cout << 0 << endl;
                continue;
            }
            n-=5000;
            tmp=0;
            if(n<3000){
                tmp=n*0.03;
            }else if(n<=12000){
                tmp=90+(n-3000)*0.1;
            } else if(n<=25000){
                tmp=990+(n-12000)*0.2;
            } else if(n<=35000){
                tmp=990+2600+(n-25000)*0.25;
            } else if(n<=55000){
                tmp=990+2600+2500+(n-35000)*0.3;
            } else if(n<=80000){
                tmp=990+2500+2600+6000+(n-55000)*0.35;
            } else {
                tmp=990+2500+2600+6000+8750+(n-80000)*0.45;
            }
            result=tmp+g;
            cout<<result<<endl;
        }
    }
}

第二题:密码强度判断

#include <iostream>
#include <string>
#include <vector>

using namespace std;
string test[6]={"password","admin","qwerty","hello","iloveyou","112233"};
inline bool isA(char& c){
    if(c>'Z'||c<'A'){
        return false;
    } else {
        return true;
    }
}
inline bool isa(char& c){
    if(c>'z'||c<'a'){
        return false;
    } else {
        return true;
    }
}
inline bool isNumber(char& c){
    if(c>'9'||c<'0')
        return false;
    else
        return true;
}

inline bool isSp(char & c){
    int t=c;
    if(c==33||(c>34&&c<39)||(c>39&&c<48)||(c>59&&c<65)||c==91||(c>92&&c<96)||c==123||c==125){
        return  true;
    } else
        return false;
}

bool checkAll(string& str){
    auto len=str.size();
    bool A= false,a= false,n= false,sp= false;
    for(auto i=0;i<len;++i){
        if(!A&&isA(str[i]))
            A=true;
        else if(!a&&isa(str[i]))
            a=true;
        else if(!n&&isNumber(str[i]))
            n=true;
        else if(!sp&&isSp(str[i]))
            sp=true;
    }
    if(A&&a&&n&&sp)
        return true;
    else
        return false;
}

bool checkNumber(string& str){
    auto len=str.size()-1;
    for(auto i=1;i<len;++i){
        if(isNumber(str[i-1])&&isNumber(str[i])&&isNumber(str[i+1])&&(2*str[i])==(str[i-1]+str[i+1]))
            return false;
    }
    return true;
}

bool checkAlpha(string &str){
    auto len=str.size()-1;
    for(auto i=1;i<len;++i){
        if(isA(str[i-1])&&isA(str[i])&&isA(str[i+1])&&((str[i])==(str[i-1]+1)&&((str[i]+1)==str[i+1])))
            return false;
        else if(isa(str[i-1])&&isa(str[i])&&isa(str[i+1])&&((str[i])==(str[i-1]+1)&&((str[i]+1)==str[i+1])))
            return false;
    }
    return true;
}

bool solve(string & str){
    if(str.size()<8)
        return false;
    for(auto i=0;i<6;++i){
        if(str.find(test[i])!=string::npos)
            return false;
    }
    if(!checkAll(str))
        return false;
    if(!checkNumber(str))
        return false;
    if(!checkAlpha(str))
        return false;
    return true;
}

int main(){
    string str;
    int m;
    while (cin>>m){
        vector<string> v(m);
        for(auto i=0;i<m;++i){
            cin>>str;

            if(solve(str))
                v[i]="yes";
            else
                v[i]="no";
        }
        for(auto i=0;i<m;++i){
            cout<<v[i]<<endl;
        }
    }
    return 0;
}

刚写到第二题就接到腾讯互娱的面试电话,接完电话笔试还剩22分钟。凉凉...

展开阅读全文

没有更多推荐了,返回首页