I'm trying to solve the problem 2253 - Password Validator , but it is giving 10% wrong answer, but all my tests are working, can anyone find the error?
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int validade(char *S) {
int i, maiuscula = 0, minuscula = 0, numero = 0, tam = strlen(S) - 1;
if(tam < 6 || tam > 32)
return 0;
for(i = 0; i < tam; i++) {
if(isupper(S[i]))
maiuscula = 1;
else if(islower(S[i]))
minuscula = 1;
else if(isdigit(S[i]))
numero = 1;
else
return 0;
}
return maiuscula * minuscula * numero;
}
int main() {
char S[100];
while(fgets(S, 100, stdin) != NULL)
printf(validade(S) ? "Senha valida.\n" : "Senha invalida.\n");
return 0;
}