+ 1

Palindromes & test

Hi! I wrote the code C++ for detect numbers palindromes, but the test #3 dont pass... https://code.sololearn.com/c8GXLenAU1q0/?ref=app What is numbers on test 3, which is calculated incorrectly?

23rd Aug 2021, 8:13 AM
Альберт Haf
Альберт Haf - avatar
4 Respostas
+ 2
I tested your code and it seems to work ok. I tried entering 0123210, which returned false, so maybe this is the problem. My suggestion: Turn your integer into a string. Reverse the string. Compare the reversed string to the original string. You may find this approach a lot simpler.
23rd Aug 2021, 8:33 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
You are manually defining the length by this line, int a=5 either take in a string and assign to a the length of string. And then convert that string to number . Or you can follow what Rik Wittkopp suggested
23rd Aug 2021, 8:44 AM
Abhay
Abhay - avatar
+ 2
Thanx for all! Martin's advice helped. How did you find out about libraries? On the course, "the reverse" did not find such a thing.
25th Aug 2021, 9:26 AM
Альберт Haf
Альберт Haf - avatar
0
How to find zero at beginning of a number (int)? 010 for example
23rd Aug 2021, 1:10 PM
Альберт Haf
Альберт Haf - avatar