Project Euler #4 in C++: largest palindrome product of two 3-digit numbers
Problem:Project Euler #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.
Any reviews are accepted.
#include <iostream>
#include <algorithm>
#include <string>
bool isPalindrome(std::string num);
int findLargestProduct();
int main(){
std::cout << findLargestProduct() << std::endl;
return 0;
}
bool isPalindrome(std::string num){
std::string oldnum = num;
reverse(oldnum.begin(),oldnum.end());
if(oldnum == num)
return true;
else
return false;
}
int findLargestProduct(){
int largest,prod =0;
for(int i =100;i<=999;i++){
for(int j =100; j<=999;j++){
prod = i*j;
if(isPalindrome(std::to_string(prod)) && prod > largest){
largest = prod;
}
}
}
return largest;
}
Project Euler #4 in C++
Problem:
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.
Any reviews are accepted.
#include <iostream>
#include <algorithm>
#include <string>
bool isPalindrome(std::string num);
int findLargestProduct();
int main(){
std::cout << findLargestProduct() << std::endl;
return 0;
}
bool isPalindrome(std::string num){
std::string oldnum = num;
reverse(oldnum.begin(),oldnum.end());
if(oldnum == num)
return true;
else
return false;
}
int findLargestProduct(){
int largest,prod =0;
for(int i =100;i<=999;i++){
for(int j =100; j<=999;j++){
prod = i*j;
if(isPalindrome(std::to_string(prod)) && prod > largest){
largest = prod;
}
}
}
return largest;
}
Project Euler #4 in C++: largest palindrome product of two 3-digit numbers
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.
Any reviews are accepted.
#include <iostream>
#include <algorithm>
#include <string>
bool isPalindrome(std::string num);
int findLargestProduct();
int main(){
std::cout << findLargestProduct() << std::endl;
return 0;
}
bool isPalindrome(std::string num){
std::string oldnum = num;
reverse(oldnum.begin(),oldnum.end());
if(oldnum == num)
return true;
else
return false;
}
int findLargestProduct(){
int largest,prod =0;
for(int i =100;i<=999;i++){
for(int j =100; j<=999;j++){
prod = i*j;
if(isPalindrome(std::to_string(prod)) && prod > largest){
largest = prod;
}
}
}
return largest;
}
Project Euler #4 c++in C++
Problem: 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.
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.
Please review my code!Any reviews are accepted.
#include <iostream>
#include <algorithm>
#include <string>
bool isPalindrome(std::string num);
int findLargestProduct();
int main(){
std::cout << findLargestProduct() << std::endl;
return 0;
}
bool isPalindrome(std::string num){
std::string oldnum = num;
reverse(oldnum.begin(),oldnum.end());
if(oldnum == num)
return true;
else
return false;
}
int findLargestProduct(){
int largest,prod =0;
for(int i =100;i<=999;i++){
for(int j =100; j<=999;j++){
prod = i*j;
if(isPalindrome(std::to_string(prod)) && prod > largest){
largest = prod;
}
}
}
return largest;
}
~
Project Euler #4 c++
Problem: 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.
Please review my code!
#include <iostream>
#include <algorithm>
#include <string>
bool isPalindrome(std::string num);
int findLargestProduct();
int main(){
std::cout << findLargestProduct() << std::endl;
return 0;
}
bool isPalindrome(std::string num){
std::string oldnum = num;
reverse(oldnum.begin(),oldnum.end());
if(oldnum == num)
return true;
else
return false;
}
int findLargestProduct(){
int largest,prod =0;
for(int i =100;i<=999;i++){
for(int j =100; j<=999;j++){
prod = i*j;
if(isPalindrome(std::to_string(prod)) && prod > largest){
largest = prod;
}
}
}
return largest;
}
~
Project Euler #4 in C++
Problem:
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.
Any reviews are accepted.
#include <iostream>
#include <algorithm>
#include <string>
bool isPalindrome(std::string num);
int findLargestProduct();
int main(){
std::cout << findLargestProduct() << std::endl;
return 0;
}
bool isPalindrome(std::string num){
std::string oldnum = num;
reverse(oldnum.begin(),oldnum.end());
if(oldnum == num)
return true;
else
return false;
}
int findLargestProduct(){
int largest,prod =0;
for(int i =100;i<=999;i++){
for(int j =100; j<=999;j++){
prod = i*j;
if(isPalindrome(std::to_string(prod)) && prod > largest){
largest = prod;
}
}
}
return largest;
}
Project Euler #4 c++
Problem: 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.
Please review my code!
#include <iostream>
#include <algorithm>
#include <string>
bool isPalindrome(std::string num);
int findLargestProduct();
int main(){
std::cout << findLargestProduct() << std::endl;
return 0;
}
bool isPalindrome(std::string num){
std::string oldnum = num;
reverse(oldnum.begin(),oldnum.end());
if(oldnum == num)
return true;
else
return false;
}
int findLargestProduct(){
int largest,prod =0;
for(int i =100;i<=999;i++){
for(int j =100; j<=999;j++){
prod = i*j;
if(isPalindrome(std::to_string(prod)) && prod > largest){
largest = prod;
}
}
}
return largest;
}
~