Java Saved Program: serene-terrain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


public class Script{

     public static void main(String []args){
        int [][] m = 
        { 
           { 0, 0, 1 },
           { 0, 0, 2 },
           { 0, 0, 3 },
           { 0, 1, 0 },
           { 0, 1, 1 },
           { 0, 1, 2 },
           { 0, 2, 0 },
           { 0, 2, 1 },
           { 0, 3, 0 },
           { 1, 0, 0 },
           { 1, 0, 1 },
           { 1, 0, 2 },
           { 1, 1, 0 },
           { 1, 1, 1 },
           { 1, 2, 0 },
           { 2, 0, 0 },
           { 2, 0, 1 },
           { 2, 1, 0 },
           { 3, 0, 0 }
        };

        int r,c;
        /*
        for (r=0; r < m.length; r++)
        {
            for (c=0; c < m[r].length; c++)
            {
                System.out.print(m[r][c] + " ");
            }
            System.out.println("");
        }
        System.out.println("");
        */
        for (int pos=1; pos<=52; pos++)
        {
            for (int c1=1; c1<52; c1++)
            {
                for (int c2=c1+1; c2<52; c2++)
                {
                    for (int c3=c2+1; c3<52; c3++)
                    {
                        for (r=0; r < m.length; r++)
                        {
                            if ((m[r][0] * c1 + m[r][1] * c2 + m[r][2] * c3) == pos)
                                System.out.println(pos + " = " +
                                                   m[r][0] + " * " + c1 + " " +
                                                   m[r][1] + " * " + c2 + " " +
                                                   m[r][2] + " * " + c3);
                        }
                    }
                }
            }
        }
    }
}

		
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs