Advertisement
nezirdemko

Matrica Shume

Nov 12th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. public class MatricaShume {
  2.  
  3.     public static void main(String[] args) {
  4.  
  5.         int m1[] = {76, 84, 12, 1, 3, 88, 4};
  6.         int m2[] = {20, 27, 4, 6, 19, 50, 12};
  7.         int shM1 = 0, shM2 = 0;
  8.  
  9.         // Shuma e matrices 1
  10.         for (int i = 0; i < m1.length; i++) {
  11.                 shM1 += m1[i];
  12.         }
  13.  
  14.         // Shuma e matrices 2
  15.         for (int j = 0; j < m2.length; j++) {
  16.                 shM2 += m2[j];
  17.         }
  18.  
  19.         // Shuma e matricave
  20.         System.out.println("Shuma e matrices se pare: " + shM1);
  21.         System.out.println("Shuma e matrices se dyte: " + shM2);
  22.         System.out.println("Shuma e 2 matricave: " + (shM1 + shM2));
  23.  
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement