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

前端 未结 17 991
天涯浪人
天涯浪人 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:12

    i did this my way , but m not sure if this is the most efficient way of doing this .
    
    package problems;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    
    
      public class P_4 {
    
    /**
     * @param args
     * @throws IOException 
     */
    static int[] arry = new int[6];
    static int[] arry2 = new int[6];
    
    public static boolean chk()
    {
        for(int a=0;a100;x--)
        for(int y=999;y>100;y--)
            {
            i=0;
                z=x*y;
                while(z>0)
                    {
                        temp=z%10;
                        z=z/10;
                        arry[i]=temp;
                        i++;
                    }
    
                for(int k = arry.length;k>0;k--)
                            arry2[arry.length- k]=arry[k-1];
    
        if(chk())
        {
            System.out.print("pelindrome = ");
    
    for(int l=0;l

提交回复
热议问题