Advertisement
Zeshin

minmaxmatrix

Mar 15th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. public class minmaxmatrix {
  2.     public static void main(String[] args) {
  3.         int arr[][]= {{3,5,71,56},
  4.                     {33,54,312},
  5.                     {35,57,71,56,33}
  6.         };
  7.         for(int i = 0;i<arr.length;i++){
  8.             int max = Integer.MIN_VALUE;
  9.             int min = Integer.MAX_VALUE;
  10.             double average = 0;
  11.             double sum = 0;
  12.             for(int j = 0;j<arr[i].length;j++){
  13.                 if(max < arr[i][j]){
  14.                     max = arr[i][j];
  15.                 }
  16.                 if(min > arr[i][j]){
  17.                     min = arr[i][j];
  18.                 }
  19.                 sum+=arr[i][j];
  20.                 average = sum/arr[i].length;
  21.             }
  22.             System.out.format(min+" "+max+" "+sum+" %.2f", average);
  23.             System.out.println();
  24.         }
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement