1081 检查密码
Posted gzu_zb
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1081 检查密码相关的知识,希望对你有一定的参考价值。
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805261217153024
题解:
1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int main() { 5 int n; 6 cin >> n; 7 getchar(); 8 string str; 9 while (n--) { 10 getline(cin, str); 11 int s_num = 0, s_zimu = 0, s_dot = 0, s_blank=0, s_else = 0; 12 if (str.size() < 6) cout << "Your password is tai duan le." << endl; 13 else { 14 for (int i = 0; i < str.size(); i++) { 15 if ((str[i] >= ‘a‘&&str[i] <= ‘z‘) || (str[i] >= ‘A‘&&str[i] <= ‘Z‘)) 16 s_zimu++; 17 else if (str[i] >= ‘0‘&&str[i] <= ‘9‘) 18 s_num++; 19 else if (str[i] == ‘.‘) 20 s_dot++; 21 else 22 s_else++; 23 } 24 if (s_else != 0) cout << "Your password is tai luan le." << endl; 25 else { 26 if (s_zimu == 0) cout << "Your password needs zi mu." << endl; 27 else if (s_num == 0) cout << "Your password needs shu zi." << endl; 28 else cout << "Your password is wan mei." << endl; 29 } 30 } 31 } 32 return 0; 33 }
以上是关于1081 检查密码的主要内容,如果未能解决你的问题,请参考以下文章