密码
#include <iostream> #include <string> #include <set> using namespace std; int main() { string s; char p[7] = {'~','!','@','#','$','%','^'}; int n, a, b, c, d; cin >> n; set<char> t; for(int i = 0; i < 7; ++ i) t.insert(p[i]); while(n --) { a = 0, b = 0, c = 0, d = 0; cin >> s; if(s.length() < 8 || s.length() > 16) { cout << "NO" << endl; } else { for(int i = 0; i < s.length(); ++ i) { if(s[i] >= 'A' && s[i] <= 'Z') a = 1; else if(s[i] >= 'a' && s[i] <= 'z') b = 1; else if(s[i] >= '0' && s[i] <= '9') c = 1; else if(t.find(s[i]) != t.end()) d = 1; } if(a + b + c + d >= 3) cout << "YES" << endl; else cout << "NO" << endl; } } return 0; }