提交记录 #206
提交时间:2024-11-12 20:34:42
语言:c
状态:Unaccepted
编译情况:编译成功
固定测试点#1:
固定测试点#2:
附加测试点暂不可用
36【应用】安全的密码
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX_LENGTH 20
void check_safe(char *passw) {
int l = strlen(passw);
int has_upper = 0, has_lower = 0, has_digit = 0, has_other = 0;
if (l < 6) {
printf("Not Safe\n");
return;
}
for (int i = 0; i < l; i++) {
if (isdigit(passw[i])) {
has_digit = 1;
} else if (isupper(passw[i])) {
has_upper = 1;
} else if (islower(passw[i])) {
has_lower = 1;
} else {
has_other = 1;
}
}
int char_type = has_digit + has_upper + has_lower + has_other;
if (char_type == 1) {
printf("Not Safe\n");
} else if (char_type == 2) {
printf("Medium Safe\n");
} else {
printf("Safe\n");
}
}
int main() {
int N;
char passw[MAX_LENGTH + 1];
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%s", passw);
check_safe(passw);
}
return 0;
}