杭电2043密码
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2043
感觉自己读题太不认真啦!
第一次没有考虑密码的长度。欠揍·······
AC代码:
#include <cstdlib> #include <iostream> #include <string.h> using namespace std; int main(int argc, char *argv[]) { int m,len; cin>>m; char str[50]; getchar(); while(m--) { int sum=0,a=0,b=0,c=0,d=0; gets(str); len=strlen(str); for(int i=0;i<len;i++) { if(str[i]>='A'&&str[i]<='Z') a=1; if(str[i]>='0'&&str[i]<='9') b=1; if(str[i]>='a'&&str[i]<='z') c=1; if(str[i]=='~'||str[i]=='!'||str[i]=='@'||str[i]=='#'||str[i]=='$'||str[i]=='%'||str[i]=='^') d=1; } sum=a+b+c+d; if(sum>=3&&len>=8&&len<=16) cout<<"YES"<<endl; else cout<<"NO"<<endl; } system("PAUSE"); return EXIT_SUCCESS; }