public class W1E5
{
    public static void main (String[] args)
    {
        int myArray[][] = new int[][] {{1 ,2 ,3 ,4 ,5}, {7 ,-2 ,6 ,8 ,-3}, {11, 90, 3, -1, 0}, {5, 19, 13, 7, 29}, {6, 5, 22, 33, 5}};
        if (myArray.length == myArray[0].length)
        {
            int largestAvg = getLargestAverage(myArray);
            for(int i=0; i<myArray.length; i++)
                System.out.print(myArray[i][i] + "  ");
            System.out.println();
            for(int i=0; i<myArray.length; i++)
                System.out.print(myArray[i][myArray.length - i - 1] + "  ");
            System.out.println();
            for(int i=0; i<myArray.length; i++)
                System.out.print(myArray[i][largestAvg] + "  ");
        }
        System.exit(0);
    }

    private static int getLargestAverage(int myArray[][])
    {
        int largestIndex = 0;
        double largestValue = 0;
        double[] columnAverage = new double[myArray.length];
        for(int i=0; i<myArray.length; i++)
            columnAverage[i] = averageColumn(myArray, i);
        for(int i=0; i<columnAverage.length; i++)
            if (columnAverage[i] > largestValue)
            {
                largestValue = columnAverage[i];
                largestIndex = i;
            }
        return largestIndex;
    }

    private static double averageColumn(int myArray[][], int colIndex)
    {
        double columnTotal = 0;
        for(int i=0; i<myArray.length; i++)
            columnTotal += myArray[i][colIndex];
        return ((double) (columnTotal / (myArray.length)));
    }

}