1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int m,c,i; 6 char s[51]; 7 while(scanf("%d",&m)!=EOF) 8 { 9 while(m--) 10 { 11 int t1=0,t2=0,t3=0,t4=0,sum=0; 12 scanf("%s",&s); 13 getchar(); 14 c=strlen(s); 15 if(c<=50) 16 { 17 for(i=0;i<c;i++) 18 { 19 if(s[i]>='A'&&s[i]<='Z') 20 t1=1; 21 if(s[i]>='a'&&s[i]<='z') 22 t2=1; 23 if(s[i]>='0'&&s[i]<='9') 24 t3=1; 25 if(s[i]==126 ||s[i]==33 ||s[i]==64 ||s[i]==35 ||s[i]==36 ||s[i]==37 ||s[i]==94) 26 t4=1; 27 } 28 sum=t1+t2+t3+t4; 29 if(sum>=3&&c>=8&&c<=16) 30 printf("YES "); 31 else 32 printf("NO "); 33 } 34 else 35 break; 36 } 37 38 } 39 40 }
注意最后记得判断密码的长度是不是在8和16之间,仔细