pTutorial

New way to learn Programming

Java array triangle

1 2 3
4 5 6
7 8 9

Java array lowest element in lower triangular matrix

package arrayexample;
public class LowestElementInLowerHalf {
    public static void main(String... z){
    int b=min(new int[][] {{101,2,1},{4000,50,6},{7,10,9}});
    System.out.println("minimum number in this array="+b);
    }
    static int min(int d[][])
    {
        int c=d[0][0];
        for(int i=0;i<d.length;i++){
            for(int j=0;j<d[i].length;j++){
                if(j==i+1){
                    break;
                }
                if(c>d[i][j])
                {
                    c=d[i][j];
                }
            }
        }
        return c;
    }
}

Output

minimum number in this array=7 

See Also


QUOTES OF THE DAY

Goal is tired by fire, brave men by adversity.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER