Advertisement
Zeshin

Koloni

Mar 29th, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. public class OPP2903 {
  2.     public static void main(String[] args) {
  3.         int[][] matrix = {
  4.                 {4,4,23,3,54},
  5.                 {4,4,23,1,54},
  6.                 {4,69,23,3,54},
  7.         };
  8.         //max min sum avverage on col
  9.         for(int i =0;i<matrix[0].length;i++){
  10.             int max = Integer.MIN_VALUE;
  11.             int min = Integer.MAX_VALUE;
  12.             double sum = 0;
  13.             double average = 0;
  14.             for(int j =0;j<matrix.length;j++){
  15.                 sum+=matrix[j][i];
  16.                 if(max < matrix[j][i]){
  17.                     max = matrix[j][i];
  18.                 }
  19.                 if(min > matrix[j][i] ){
  20.                     min = matrix[j][i];
  21.                 }
  22.             }
  23.             average = sum / matrix.length;
  24.             System.out.println("COL "+i+": - Max value: "+max+" Min Value: "+min+" Sum: "+sum+" Average: "+average);
  25.         }
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement