My program is not working with 2 out of 6 test cases.
pls tell me where i have gone wrong.
Wrote the code in C..
Thanks in Advance.
The aren't much changes needed in code but these:
1.scanf, thats ought to cause the problem.
No where was it mentioned in the problem that a password can't contain a space hence there might be one in it and since scanf() takes an input until the first space or newline is encountered for a password like this
"he12 @!world" it will only read "he12".
So instead use fgets() like this:
fgets(pwd,30,stdin);//reads 30 characters from standard input and stores it in char array pwd.It stops reading if only newline is encountered
2.No need for the isspace() as it is redundant as mentioned and hence not required.
3.You should prefer using the i++ instead of the i-- ,as it's easier to read and convinient.
Where is a scanf statement in your code ? You are not reading the password at all. Your test cases are passing by fluke
Also you are starting with
i = n-1, then your for loop should have i -- instead of i++
Also isspace check is redundant. passwords don't have spaces in them (at least i have never seen it)
~ swim ~
Thank you so much.Just executed the code successfully.Real problem lied in using i++ instead of i--.Scannig of string dosent making sense at all in that program.It is showing same output for no scanning string also.