+ 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; }3 Réponses
+ 2
You could check it on the playground with some examples and see what happends.
+ 2
Please refer to other threads on this subject. You have to check if there are two *different* special characters, not just *any* two.
https://www.sololearn.com/discuss/2305447/?ref=app
https://www.sololearn.com/discuss/2273511/?ref=app
https://www.sololearn.com/discuss/2295972/?ref=app
https://www.sololearn.com/discuss/2289317/?ref=app
https://www.sololearn.com/discuss/2297070/?ref=app
https://www.sololearn.com/discuss/2284108/?ref=app
https://www.sololearn.com/discuss/2296780/?ref=app
https://www.sololearn.com/discuss/2290349/?ref=app
https://www.sololearn.com/discuss/2275063/?ref=app
https://www.sololearn.com/discuss/2288020/?ref=app
https://www.sololearn.com/discuss/2300345/?ref=app
https://www.sololearn.com/discuss/2311868/?ref=app
https://www.sololearn.com/discuss/2279581/?ref=app
+ 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.