Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

Highest Palindrome - C++ Code Bank


Highest Palindrome
Finds the highest palindrome from two multiples under 1000x1000; can be easily modified for higher 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.
                #include <iostream>
#include <string.h>
using namespace std;
int main(){
    



int a,b,c,d,e,f,g,h,l,r,x,y,z;
string t[10],u,v;
a=b=c=d=e=f=g=x=0;



for (a=100;a<1000;a++){
 for (b=100;b<1000;b++){
   c=0;
   d=(a*b);
   h=d;
   z=0;
   for(int dd=6;dd>0;dd--){

      e=(d%10);    
      switch (e){
               
        case 0:
         t[dd]="0";
         break;
                       
        case 1:
         t[dd]="1";
         break;
                       
        case 2:
         t[dd]="2";
         break;
                       
        case 3:
         t[dd]="3";
         break;
                        
         case 4:
          t[dd]="4";
          break;
                       
         case 5:
          t[dd]="5";
          break;
                                            
         case 6:
          t[dd]="6";
          break;
                       
         case 7:
          t[dd]="7";
          break;

         case 8:
          t[dd]="8";
          break;
                      
         case 9:
          t[dd]="9";
          break;

         d=d/10;
         z++;
                   
       }                     
      
       if(t[1]==t[6]){
        if(t[2]==t[5]){
         if(t[3]==t[4]){
          if(h>x){
              x=h;
       }}}}
                                         
                   
                   
 }}
 
 cout<<x<<" a "<<a<<" b "<<b<<"\n";
 system("pause"); 
}
            
Comments
Sorry but there are no comments to display