Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class DvumerenMasiv {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int [][]arr = {
- {5, 6, 7},
- {12, 8, 2},
- {3, 9, 11}
- };
- for (int r = 0; r < arr.length ; r++) {
- int[] currnetRow = arr[r];
- int sum = 0;
- int min = (Integer.MAX_VALUE);
- int max = (Integer.MIN_VALUE);
- for (int c = 0; c < currnetRow.length ; c++) {
- int currentElementOnRow = currnetRow[c];
- if(min > currentElementOnRow){
- min = currentElementOnRow;
- }
- if(max < currentElementOnRow){
- max = currentElementOnRow;
- }
- sum += currentElementOnRow;
- }
- double avg = (double) sum / (double) currnetRow.length;
- String formatAvg = String.format("%.2f", avg);
- System.out.println(" index: " + r +" Sum: " + sum + " Min: " + min + " Max: " + max + " Avg: " + formatAvg);
- System.out.printf("index: %d Sum: %d Min: %d Max: %d Average %.2f",r,sum,min,max,avg);
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement