Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- // write your code here
- Scanner scan = new Scanner(System.in);
- int matrix[][]=new int[3][3];
- for (int i=0;i<3;i++){
- for (int j=0;j<3;j++){
- System.out.println("Unos clana matrice");
- matrix[i][j]=scan.nextInt();
- }
- }
- System.out.println("ISPIS MATRICE");
- for (int i=0;i<3;i++){
- for (int j=0;j<3;j++){
- System.out.print(matrix[i][j]+" ");
- }
- System.out.println();
- }
- int determinant,x,y,z;
- x=(matrix[0][0] * (matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1]));
- y=(matrix[0][1] * (matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0]));
- z=(matrix[0][2] * (matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]));
- determinant= x - y + z;
- System.out.println("Determinanta za 3x3 matricu je "+determinant);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement