Description
Input
Output
Sample Input
Sample Output
#include <iostream> #include <string> using namespace std; bool f(string str,char a,char b) { bool flag=false; int n=str.length(); for(int i=0;i<n;i++){ if(str[i]>=a&&str[i]<=b){ flag=true; break; } } return flag; } bool g(string str) { bool flag=false; int n=str.length(); for(int i=0;i<n;i++){ if(str[i]==‘:‘||str[i]==‘~‘||str[i]==‘!‘||str[i]==‘@‘||str[i]==‘#‘||str[i]==‘$‘||str[i]==‘%‘||str[i]==‘^‘){ flag=true; break; } } return flag; } int main() { int n,k=0,p; string str; cin>>n; while(k<n){ p=0; cin>>str; int n=str.length(); if(n>=8&&n<=16){ if(f(str,‘A‘,‘Z‘))p++; if(f(str,‘a‘,‘z‘))p++; if(f(str,‘0‘,‘9‘))p++; if(g(str))p++; if(p>=3)cout<<"YES"<<endl; else cout<<"NO"<<endl; } else cout<<"NO"<<endl; k++; } //system("pause"); return 0; }
原文:http://www.cnblogs.com/farewell-farewell/p/5185282.html