Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. int[][] twoDimArray = new int[5][5];
  7. int[] zap = {0, 0, 0, 0, 0};
  8. for (int i = 0; i < 5; i++) {
  9. for (int j = 0; j < 5; j++) {
  10. twoDimArray[i][j] = (int)(-20 + Math.random()*40);
  11. if(twoDimArray[i][j] < 0){
  12. zap[i] = 1;
  13.  
  14. }
  15.  
  16. }
  17. }
  18. for (int []anArr : twoDimArray) {
  19. for (int ananArr : anArr) {
  20. System.out.printf("%d ", ananArr);
  21. }
  22. System.out.println();
  23. }
  24. int sum = 0;
  25. for (int i = 0; i < 5; i++) {
  26. if(zap[i] == 1){
  27. for(int j = 0; j < 5; j++){
  28. sum = sum + twoDimArray[i][j];
  29. }
  30. System.out.printf("%d ", sum);
  31. sum = 0;
  32. }
  33. }
  34. // System.out.printf("Сумма модулей элементов нижней диагонали в сглаженной двумерной матрице : %.2f", module );
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement