Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1.  
  2. package program;
  3.  
  4. import java.util.Random;
  5. import java.util.Scanner;
  6.  
  7. public class Program {
  8.  
  9. /**
  10. * @param args the command line arguments
  11. */
  12. public static void main(String[] args) {
  13. // TODO code application logic here
  14. Scanner tastatura = new Scanner(System.in);
  15. int[][] matrica = new int[5][5];
  16. Random r = new Random();
  17. for(int i = 0;i<5; i++){
  18. for(int j = 0;j<5;j++){
  19. // matrica[i][j] = r.nextInt(100-10)+10;
  20. System.out.println("Unesi broj za poziciju:" + i +", "+j);
  21. matrica[i][j] = tastatura.nextInt();
  22. }
  23. }
  24.  
  25. for(int i = 0;i<5; i++){
  26. for(int j = 0;j<5;j++){
  27. System.out.print(matrica[i][j]+ " ");
  28. }
  29. System.out.println();
  30. }
  31. for(int i = 0;i<5;i++){
  32. int sum = 0;
  33. for(int j =0;j<5;j++){
  34. sum += matrica[j][i];
  35. }
  36. System.out.println("Zbir kolone: " + i + ": " + sum);
  37. }
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement