+ 1

I have created code for password validation.It has satisfied 12/13 cases.Why It is giving 1 failed case.Look and please tell me.

#include<stdio.h> #include<string.h> int main() { char s[100]; gets(s); int i,length,n=0,ch=0; length=strlen(s); for(i=0;i<length;i++) { if(s[i]==0||s[i]==1||s[i]==2||s[i]==3||s[i]==4||s[i]==5||s[i]==6||s[i]==7||s[i]==8||s[i]==9) { n++; } if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='

#x27;||s[i]=='%'||s[i]=='&'||s[i]=='*') { ch++; } } if((length>=7)&&(ch>=2)||(n>=2)) { printf("Strong"); } else { printf("Weak"); } return 0; }

31st May 2020, 5:39 PM
Aniket Gade
Aniket Gade - avatar
3 ответов
+ 2
You could check it on the playground with some examples and see what happends.
31st May 2020, 5:48 PM
JaScript
JaScript - avatar
+ 2
#include<stdio.h> #include<string.h> int main() { char s[100]; scanf("%s",s); int i,length,numbers=0,specialcharacter=0; length=strlen(s); for(i=0;s[i]!='\0';i++) { if(s[i]>='0'&& s[i]<='9') { numbers++; } else if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='
#x27;||s[i]=='%'||s[i]=='&'||s[i]=='*') { specialcharacter++; } } if((length>=7)&&(specialcharacter>=2)&&(numbers>=2)) { printf("Strong"); } else { printf("Weak"); } return 0; } Hey guy's I solved it myself.Look the just some difference.
1st Jun 2020, 5:16 AM
Aniket Gade
Aniket Gade - avatar