#include <stdio.h>
#include <stdbool.h>
#include <string.h>
bool is_secure_password(const char* password);
int main()
{int M;char password[51];// 读取输入中的密码数量 Mscanf("%d", &M);// 处理每个密码for (int i = 0; i < M; ++i){// 读取密码scanf("%s", password);// 检查密码是否安全并输出结果if (is_secure_password(password)){printf("YES\n");}else{printf("NO\n");}}return 0;
}
// 函数定义
bool is_secure_password(const char* password)
{// 检查密码长度int len = strlen(password);if (8 <= len && len <= 16){// 检查密码字符类别bool categories[4] = { false }; // 大写字母、小写字母、数字、特殊符号for (int i = 0; i < len; ++i) {char current = password[i];if ('A' <= current && current <= 'Z'){categories[0] = true;}else if ('a' <= current && current <= 'z'){categories[1] = true;}else if ('0' <= current && current <= '9'){categories[2] = true;}else if (strchr("~!@#$%^&", current) != NULL){categories[3] = true;}}// 判断密码是否包含至少三组字符类别if (categories[0] + categories[1] + categories[2] + categories[3] >= 3){return true;}}return false;
}