Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Project Euler("https://projecteuler.net/archives")
- Problem 4
- 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.
- */
- int main(){
- int size = 1000; long product = 0, max = 0;
- char buffer[10];
- for(int i = 0 ; i < size; i ++){
- for(int j = 0; j < size; j++){
- product = i * j;
- _itoa_s(product, buffer,10);
- if(buffer[0] == buffer[5] && buffer[1] == buffer[4] && buffer[2] == buffer[3]){
- if(max < product) max = product;
- }
- }
- }
- cout << max << endl;
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment