a guest May 19th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include "euler_4.h"
- * A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
- * Find the largest palindrome made from the product of two 3-digit numbers.
- inline bool isPalindrome(int n)
- std::string a = std::to_string(n);
- std::string b = a;
- std::reverse(b.begin(), b.end());
- return (a == b);
- void euler_4()
- int Largest = -1, Num = -1;
- for (int i = 999; i >= 100; i--)
- for (int j = i; j >= 100; j--)
- Num = j * i;
- if (isPalindrome(Num))
- if (Num > Largest)
- Largest = Num;
- std::cout << "The largest palindrome is " << Largest;
RAW Paste Data