原题:http://acm.hdu.edu.cn/showproblem.php?pid=2043
思路:
水题,没什么好说的
我承认那个if语句写得真的丑,省时间而已= =
源代码:
#include<cstdio> #include<cstdlib> #include<cstring> int main() { int n, N; char arr[60]; scanf("%d\n", &N); while (N--) { int Uletter=0, Lletter=0, Num=0, Spacial=0; scanf("%s\n", arr); n=strlen(arr); if (n<8 || n>16) { printf("NO\n"); continue; } for (int i=0;i<n;i++) if (arr[i]>='A'&&arr[i]<='Z') Uletter = 1; else if (arr[i]>='a'&&arr[i]<='z') Lletter = 1; else if (arr[i]>='0'&&arr[i]<='9') Num = 1; else if (arr[i] == '~' || arr[i] == '!' || arr[i] == '@' || arr[i] == '#' || arr[i] == '$' || arr[i] == '%' || arr[i] == '^') Spacial = 1; if ((Uletter + Lletter + Num + Spacial) >= 3) printf("YES\n"); else printf("NO\n"); } return 0; }