Advertisement
Guest User

Untitled

a guest
Nov 16th, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.  
  2. public class Main {
  3.  
  4.  
  5.  
  6.     public static void main(String[] args) {
  7.     // write your code here
  8.  
  9.         Scanner scan = new Scanner(System.in);
  10.  
  11.         int matrix[][]=new int[3][3];
  12.  
  13.         for (int i=0;i<3;i++){
  14.             for (int j=0;j<3;j++){
  15.                 System.out.println("Unos clana matrice");
  16.                 matrix[i][j]=scan.nextInt();
  17.             }
  18.         }
  19.  
  20.         System.out.println("ISPIS MATRICE");
  21.         for (int i=0;i<3;i++){
  22.             for (int j=0;j<3;j++){
  23.                 System.out.print(matrix[i][j]+" ");
  24.             }
  25.             System.out.println();
  26.         }
  27.  
  28.         int determinant,x,y,z;
  29.         x=(matrix[0][0] * (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1]));
  30.         y=(matrix[0][1] * (matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0]));
  31.         z=(matrix[0][2] * (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]));
  32.         determinant= x - y + z;
  33.  
  34.         System.out.println("Determinanta za 3x3 matricu je "+determinant);
  35.  
  36.  
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement