1. 程式人生 > >1081 檢查密碼 (15 分)

1081 檢查密碼 (15 分)

!= letter 選項 color line -- col include 實現

#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 分)