fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int greatest = 0;
  7.  
  8. for(int i = 999;i>=100; --i)
  9. {
  10. for (int j =990, product; j>=100 && ((product = i*j) > greatest); j-=11)
  11. {
  12. int n = product;
  13. int rev = 0;
  14. do
  15. {
  16. rev = (rev * 10) + (product % 10);
  17. product /= 10;
  18. } while(product != 0);
  19.  
  20. if (n == rev)
  21. {
  22. cout << "Palindrome : " << i << " * " << j << " = " << n << endl;
  23. greatest = n;
  24. }
  25. }
  26. }
  27. cout << "The Greatest Palindrome Number Is : " << greatest << endl;
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Palindrome : 995 * 583 = 580085
Palindrome : 993 * 913 = 906609
The Greatest Palindrome Number Is : 906609