题解 | #密码验证合格程序#
密码验证合格程序
https://www.nowcoder.com/practice/184edec193864f0985ad2684fbc86841
#include <stdio.h>
#include <string.h>
int main(){
char str[102];
while(scanf("%s", str) != -1){
int falg[5] = {0};
int len = strlen(str);
for(int i = 0; i < len; i++){
if(str[i] >= '0' && str[i] <= '9')
falg[0] = 1;
else if(str[i] >= 'A' && str[i] <= 'Z')
falg[1] = 1;
else if(str[i] >= 'a' && str[i] <= 'z')
falg[2] = 1;
else if(str[i] >= '0' && str[i] <= '9')
falg[3] = 1;
else
falg[4] = 1;
}
int fl = 0;
for(int i = 0; i < len - 2; i++){
for(int j = i + 1; j < len; j++){
if(str[i] == str[j] && str[i + 1] == str[j+1] && str[i + 2] == str[j + 2]){
fl = 1;
break;
}
}
if(fl == 1)
break;
}
int sun = falg[0] + falg[1] + falg[2] + falg[3] +falg[4];
if(sun >= 3 && fl == 0 && len > 8)
printf("OK\n");
else
printf("NG\n");
}
return 0;
}
SHEIN希音公司福利 263人发布
查看10道真题和解析