+ 1
(SOLVED)Extra-Terrestrials my code answer is incorrect. Pls, why?
Pls someone can tell me why my answer is not accepted? All tests fail my code.. https://code.sololearn.com/cc68eRVy1L0g thanks
3 ответов
+ 3
Because there is a '\0' before every reversed strings. The first loop in for loop cause it. When k = 0 you assign word + str[length] to word, whereas str[length] is '\0'. To solve it, make k = 1.
for(int k = 1 ; k <= length ; k++)
+ 4
CarrieForle is correct. It's due to the string null terminating character '\n'. Loop through the string starting from the last visible character to 0.
for(int k = length-1; k >= 0 ; k--) {
word = word + str[k];
}
+ 1
thank you guys. CarrieForle you are right. thank so much ,i haven't seen it before😩