0

Palindromic numbers C++

Hi, I am attempting to solve a problem of finding the largest palindromic number which is a product of two 3-digit integers. I tried a rather straightforward approach yet there is no output. Any advice? Here is the code: https://code.sololearn.com/cLjb5EQxlF79

19th Aug 2017, 11:42 PM
Tauras
Tauras - avatar
4 Answers
+ 1
heighest palindrom satisfying your condition is ----> 906609 ( 993 * 913) check it https://code.sololearn.com/c9Nr2Y7d5rgS/?ref=app
20th Aug 2017, 3:38 AM
sayan chandra
sayan chandra - avatar
0
Cheers. Loving the elegance of python there (and the solution, obviously). Yeah, I noticed it was a wrong assumption, so I added another loop. Still, something does not work. I think the problem lies in the if loops but not sure. int main(){ int palindrome = 0; int first = 999; int second = 999; int arr[6] = {0}; while(first>99){ while(second>99){ palindrome=first*second; for(int i=5; i>=0; i--){ arr[i] = palindrome%10; palindrome /=10; } if(arr[0] == arr[5]){ if(arr[1] == arr[4]){ if(arr[2] == arr[3]){ for (int y=0; y<6; y++){ cout<<arr[y];} return 0; } } } second--; } first--; } }
20th Aug 2017, 11:03 AM
Tauras
Tauras - avatar
0
Help Me guys
6th Jan 2021, 10:14 AM
Schawnnara Jiri Jeena-Myrr
Schawnnara Jiri Jeena-Myrr - avatar
- 1
BROTHER PALINDROME NUMBERS ARE LIKE THIS--> 121 135686531 9990000999 89098 98789 10101 HOW CAN YOU ASSUME A MULTIPLE AS 999 THERE IS ACTUALLY NO NUMBER THAT IS A MULTIPLIED VALUE OF 2 THREE DIGIT NUMBER WHERE ONE DIGIT IS 999 YOU CANT ASSUME THAT.. AS U ARE ASSUMING IT IS GIVING THE TRUE OUT PUT.. AS THERE IS NO SUCH NUMBER SO "" NO OUTPUT""..
20th Aug 2017, 3:42 AM
sayan chandra
sayan chandra - avatar