1081 检查密码 (15 分)
#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; }