标签:des style class blog c code
Time
Limit: 2000/1000 MS (Java/Others) Memory Limit:
65536/32768 K (Java/Others)
Total Submission(s):
28587 Accepted Submission(s):
11412
1 #include <cstdio> 2 #include <string.h> 3 4 using namespace std; 5 6 int main() 7 { 8 int M; 9 int len; 10 char a[55]; 11 12 scanf("%d", &M); 13 while(M--) { 14 int flag = 1; 15 int fir = 0, sec = 0, thi = 0, fou = 0; 16 17 scanf("%s", a); 18 len = strlen(a); 19 if(len < 8 || len > 16) 20 flag = 0; 21 else { 22 int judge = 0; 23 for(int i = 0; i < len; i++) { 24 if(a[i] >= ‘A‘ && a[i] <= ‘Z‘) { 25 fir = 1; 26 judge = 1; 27 } 28 if(a[i] >= ‘a‘ && a[i] <= ‘z‘) { 29 sec = 1; 30 judge = 1; 31 } 32 if(a[i] >= ‘0‘ && a[i] <= ‘9‘) { 33 thi = 1; 34 judge = 1; 35 } 36 if(a[i] == ‘~‘ || a[i] == ‘!‘ || a[i] == ‘@‘ || a[i] == ‘#‘ || a[i] == ‘$‘ || a[i] == ‘%‘ || a[i] == ‘^‘) { 37 fou = 1; 38 judge = 1; 39 } 40 if(judge == 0) 41 flag = 0; 42 } 43 } 44 if(flag*(fir*sec*thi || fir*sec*fou || fir*thi*fou || sec*thi*fou)) 45 printf("YES\n"); 46 else 47 printf("NO\n"); 48 } 49 return 0; 50 }
借鉴别人的,很简洁,很有yiyi的风范,continue:
1 #include <cstdio> 2 #include <string.h> 3 4 using namespace std; 5 6 int main() 7 { 8 int M; 9 int len; 10 char a[55]; 11 12 scanf("%d", &M); 13 while(M--) { 14 int fir = 0, sec = 0, thi = 0, fou = 0; 15 16 scanf("%s", a); 17 len = strlen(a); 18 if(len < 8 || len > 16) { 19 printf("NO\n"); 20 continue; 21 } 22 for(int i = 0; i < len; i++) { 23 if(a[i] >= ‘A‘ && a[i] <= ‘Z‘) { 24 fir = 1; 25 } 26 if(a[i] >= ‘a‘ && a[i] <= ‘z‘) { 27 sec = 1; 28 } 29 if(a[i] >= ‘0‘ && a[i] <= ‘9‘) { 30 thi = 1; 31 } 32 if(a[i] == ‘~‘ || a[i] == ‘!‘ || a[i] == ‘@‘ || a[i] == ‘#‘ || a[i] == ‘$‘ || a[i] == ‘%‘ || a[i] == ‘^‘) { 33 fou = 1; 34 } 35 } 36 if(fir+sec+thi+fou > 2) 37 printf("YES\n"); 38 else 39 printf("NO\n"); 40 } 41 return 0; 42 }
标签:des style class blog c code
原文地址:http://www.cnblogs.com/sayeter/p/3736680.html