0

Why compiler not accepting my code even then case shows correct answer

Can anyone tell me ? Why compiler not accepting my code even then case shows correct answer https://code.sololearn.com/cKjK2IEPn4rv/?ref=app

12th Oct 2021, 1:05 PM
Pranjal Pagar
Pranjal Pagar - avatar
8 Respostas
+ 3
Can you give us some more details please? What problem are you attempting to solve? Linking your code would be quite helpful too. If you are referring to a code coach task, chances are you are only solving a single test case instead of all simultaneously, or you might be printing invisible characters that don't belong into the result. Both are hard to identify without seeing your code.
12th Oct 2021, 1:17 PM
Shadow
Shadow - avatar
+ 2
1. #include <string> is missing 2. For a loop over string.length() the variable i has to be unsigned int 3. name[i] will only give you a single character! You can't compare this against '10', because this are two characters. For this purpose you have to work sub-strings. Here is your code working (without these '10' case) https://code.sololearn.com/cbWk0oN7ILa0/?ref=app
12th Oct 2021, 2:58 PM
Coding Cat
Coding Cat - avatar
+ 1
Then post here the link to your new version. Or compare it by your self with the corrected one above.
12th Oct 2021, 3:26 PM
Coding Cat
Coding Cat - avatar
+ 1
Delete this, it's not possible && (name[i]!='10') Use unsigned int for i in the loop for (unsigned int i =0;......... And include <string> Are u kidding me, or is this for the hidden camera?
12th Oct 2021, 4:11 PM
Coding Cat
Coding Cat - avatar
0
After doing changes .. then also not accepting the code... Coding Cat ... thanks
12th Oct 2021, 3:18 PM
Pranjal Pagar
Pranjal Pagar - avatar
12th Oct 2021, 4:07 PM
Pranjal Pagar
Pranjal Pagar - avatar
0
Please check my code.. i already made changes in code.
12th Oct 2021, 4:13 PM
Pranjal Pagar
Pranjal Pagar - avatar