题解 | #密码检查#
密码检查
https://www.nowcoder.com/practice/f2fbd8f61c564ca0b5feaa63ab42dae5
#include <stdio.h> #include<string.h> int main() { int n = 0; scanf("%d", &n); char password[n][200];//n行 //输入 for (int i = 0; i < n; i++) { scanf("%s", password[i]); int len = strlen(password[i]); //判断输入的字符是否合法 if (len < 8) { puts("NO"); goto here; } int judge_1 = 0;//判断是否出现大写字母 int judge_2 = 0;//判断是否出现小写字母 int judge_3 = 0;//判断是否出现数字字符 for (int j = 0; j < len; j++) { if (password[i][0] >= 48 && password[i][0] <= 57) { puts("NO"); goto here; } if (password[i][j] <= 47 && password[i][j] >= 58 && password[i][j] <= 64 && password[i][j] >= 91 && password[i][j] <= 96 && password[i][j] >= 123) { puts("NO");//数字字符,大写字母,小写字母 goto here; } else { if (password[i][j] >= 48 && password[i][j] <= 57) { judge_3 = 1; } if (password[i][j] >= 65 && password[i][j] <= 90) { judge_1 = 1; } if (password[i][j] >= 97 && password[i][j] <= 122) { judge_2 = 1; } } } if ((judge_1 == 1 && judge_2 == 1) || (judge_1 == 1 && judge_3 == 1) || (judge_2 == 1 && judge_3 == 1)) { printf("YES\n"); } else { printf("NO\n"); } here: ; } return 0; }