http://acm.hdu.edu.cn/showproblem.php?pid=2043
千万记得读题要准确,到时候得读两遍,最后一遍读的时候把句子结构都得理清楚!!!这样才能保证不丢不必要的分。
还有,dev的调试是一定要用的。!!!
#include<iostream>
#include<stack>
#include<string>
#include<cstring>
using namespace std;
int tc[7]={'~','!','@','#','$','%','^'};
bool mark[4];//标记四个符号是否有
int main(){
int M;cin>>M;
while(M--){
string str;cin>>str;
if(str.length()<8||str.length()>16){
cout<<"NO"<<endl;
continue;
}
memset(mark,false,sizeof(mark));
int num=0;//标记种类数量
for(int i=0;i<str.length();i++){
if(num>=3)break;
if(mark[0]==false&&str[i]>='A'&&str[i]<='Z'){//大写
mark[0]=true;
num++;
continue;
}
if(!mark[1]&&str[i]>='a'&&str[i]<='z'){//小写
mark[1]=true;
num++;
continue;
}
if(mark[2]==false&&str[i]>='0'&&str[i]<='9'){//数字
mark[2]=true;
num++;
continue;
}
if(mark[3]==false){//特殊符号
bool flag=false;
for(int j=0;j<7;j++){
if(str[i]==tc[j]){
flag=true;
break;
}
}
if(flag){
mark[3]=true;
num++;
}
}
}
if(num>=3)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}