+ 1
Is it possible to reverse a number ending with 0 in C++
Hi everyone, so, I just did a code coach about Palindrome numbers, so I successfully completed the challenge and I managed to reverse various numbers in my code, but I was curious about if we input a number ending with zero. The results is that I couldn't really get a completely reversed number for numbers ending or starting with zeros, e.g: 120 becomes 21 and 050 becomes just 5. https://code.sololearn.com/cn2HO5eYeFwy/?ref=app
5 Answers
+ 5
Numbers should behave this why but you could work with strings
+ 1
Yes . But it takes time and memory...you have to find the length of the number then create an array using that length then store each digit into the array then again check in the reverse way if it's equal or not......Or you have to convert it to string of characters then reverse and check both ways are little complicated and time taken
+ 1
Martin Taylor well I have seen your code it's interesting, but still if you input 050 the output is 50 is NOT a palindrome. So it doesn't work as I expect it to.