Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Main {
- public static void main(String[] args) {
- int[][] twoDimArray = new int[5][5];
- int[] zap = {0, 0, 0, 0, 0};
- for (int i = 0; i < 5; i++) {
- for (int j = 0; j < 5; j++) {
- twoDimArray[i][j] = (int)(-20 + Math.random()*40);
- if(twoDimArray[i][j] < 0){
- zap[i] = 1;
- }
- }
- }
- for (int []anArr : twoDimArray) {
- for (int ananArr : anArr) {
- System.out.printf("%d ", ananArr);
- }
- System.out.println();
- }
- int sum = 0;
- for (int i = 0; i < 5; i++) {
- if(zap[i] == 1){
- for(int j = 0; j < 5; j++){
- sum = sum + twoDimArray[i][j];
- }
- System.out.printf("%d ", sum);
- sum = 0;
- }
- }
- // System.out.printf("Сумма модулей элементов нижней диагонали в сглаженной двумерной матрице : %.2f", module );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement