Find the largest palindrome made from the product of two 3-digit numbers

前端 未结 17 993
天涯浪人
天涯浪人 2021-02-02 04:27
package testing.project;

public class PalindromeThreeDigits {

    public static void main(String[] args) {
        int value = 0;
        for(int i = 100;i <=999;i+         


        
17条回答
  •  迷失自我
    2021-02-02 05:05

    This is code in C, a little bit long, but gets the job done.:)

    #include 
    #include 
    /*
    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 palndr(int b)
    {
    int *x,*y,i=0,j=0,br=0;
    int n;
    n=b;
    while(b!=0)
    {
       br++;
       b/=10;
    }
    x=(int *)malloc(br*sizeof(int));
    y=(int *)malloc(br*sizeof(int));
    
    int br1=br;
    
    while(n!=0)
    {
        x[i++]=y[--br]=n%10;
        n/=10;
    }
    
    int ind = 1;
    for(i=0;icekmax)
                cekmax=cek;
            }
            }
       }
    
       printf("The largest palindrome is: %d\n\a",cekmax);
    }
    

提交回复
热议问题