//用最笨的方法,把5种情况都列出来,比较好理解 #include <iostream> #include <cstdlib> #include <cmath> #include <deque> #include <algorithm> #include <numeric> #include <iterator> #include <sstream> #include <iomanip> #include <vector> #include <string> using namespace std; int f1(string str) { int i; for(i=0;i<str.size();i++) { if(str[i]>='0'&&str[i]<='9') { break; } } if(i!=str.size()) { return 1; } else { return 0; } } int f2(string str) { int i; for(i=0;i<str.size();i++) { if(str[i]>='a'&&str[i]<='z') { break; } } if(i!=str.size()) { return 1; } else { return 0; } } int f3(string str) { int i; for(i=0;i<str.size();i++) { if(str[i]>='A'&&str[i]<='Z') { break; } } if(i!=str.size()) { return 1; } else { return 0; } } int f4(string str) { int i; for(i=0;i<str.size();i++) { if(str[i]=='~'||str[i]=='!'||str[i]=='@'||str[i]=='#'||str[i]=='$'||str[i]=='%'||str[i]=='^') { break; } } if(i!=str.size()) { return 1; } else { return 0; } } int main() { int n; deque<string> q; string str[100001]; cin>>n; for(int i=0;i<n;i++) { cin>>str[i]; } for(int i=0;i<n;i++) { if(f1(str[i])==0&&f2(str[i])==1&&f3(str[i])==1&&f4(str[i])==1) { q.push_back("YES"); } else if(f1(str[i])==1&&f2(str[i])==0&&f3(str[i])==1&&f4(str[i])==1) { q.push_back("YES"); } else if(f1(str[i])==1&&f2(str[i])==1&&f3(str[i])==0&&f4(str[i])==1) { q.push_back("YES"); } else if(f1(str[i])==1&&f2(str[i])==1&&f3(str[i])==1&&f4(str[i])==0) { q.push_back("YES"); } else if(f1(str[i])==1&&f2(str[i])==1&&f3(str[i])==1&&f4(str[i])==1) { q.push_back("YES"); } else { q.push_back("NO"); } } copy(q.begin(),q.end(),ostream_iterator<string>(cout,"\n")); return 0; }
解题思路:
注意事项:
参考代码:
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:1031 |
母牛的故事 (C语言代码)浏览:1308 |
简单的a+b (C语言代码)浏览:648 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:692 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:711 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:574 |
川哥的吩咐 (C++代码)浏览:1019 |
高精度加法 (C++代码)(大数加法)浏览:941 |
C二级辅导-同因查找 (C语言代码)浏览:588 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:525 |