首页 > 其他 > 详细

1081 检查密码 (15 分)

时间:2019-04-19 01:15:01      阅读:237      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n;
    string str;
    cin >> n;
    getchar();
    while (n--){
        int str_num = 0, str_letter = 0, str_dot = 0, str_other = 0;
        getline(cin, str);
        if (str.size() < 6)
            cout << "Your password is tai duan le." << endl;
        else{
            for (int i = 0; i < str.size(); i++){
                if (str[i] >= 0 && str[i] <= 9)
                    str_num++;
                else if ((str[i] >= a && str[i] <= z) || (str[i] >= A && str[i] <= Z))
                    str_letter++;
                else if (str[i] == .)
                    str_dot++;
                else
                    str_other++;
            }
            if (str_other != 0)
                cout << "Your password is tai luan le." << endl;  // 这个可以很巧妙的实现太乱了这个选项,一般都会卡在这儿
            else if (str_num == 0)
                cout << "Your password needs shu zi." << endl;
            else if (str_letter == 0)
                cout << "Your password needs zi mu." << endl;
            else
                cout << "Your password is wan mei." << endl;
        }
    }
    return 0;
}

 

1081 检查密码 (15 分)

原文:https://www.cnblogs.com/Hk456/p/10733454.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!