1081. 检查密码 (15)

查看原题目请点我这里
解题思路
这是道简单的字符串处理的题,需要注意的是要用gets接收一行字符。
代码

#include<cstdio>
#include<cstring>
int check(char s[],int m){
    int num=0,alph=0;
    for(int i=0;i<m;i++){
        if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z')){
            alph=1;
        }else if(s[i]>='0'&&s[i]<='9'){
            num=1;
        }else if(s[i]=='.'){
        }else return 1;
    }
    if(alph==1&&num==1) return 0;
    else if(alph==0&&num==1) return 3;
    else if(alph==1&&num==0) return 2;
}
int main(){
    char str[100];
    int n;
    scanf("%d",&n);
    getchar();
    while(n--){
    gets(str);
    int len=strlen(str);
    if(len<6){
        printf("Your password is ***an le.\n");
    }else if(check(str,len)==0){
        printf("Your password is wan mei.\n");
    }else if(check(str,len)==1){
        printf("Your password is tai luan le.\n");
    }else if(check(str,len)==2){
        printf("Your password needs shu zi.\n");
    }else if(check(str,len)==3){
        printf("Your password needs zi mu.\n");
    }   
    }
    return 0;
} 
全部评论

相关推荐

06-17 21:57
门头沟学院 Java
白友:噗嗤,我发现有些人事就爱发这些,明明已读不回就行了,就是要恶心人
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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