import java.io.*;
class invers
{
public static void main (String[]args) throws Exception
{
BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
System.out.println("");
System.out.println("=======INVERS=======");
System.out.println("Ordo Matriks = 2 x 2");
int [][]matrika = new int[2][2];
System.out.println("Masukan Elemen Matriksnya:");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
System.out.print("Elemen ["+(i+1)+","+(j+1)+"]: ");
matrika[i][j]=Integer.parseInt(input.readLine());
}
}
System.out.println("");
System.out.println("Matriknya: ");
for(int i=0;i<2;i++)
{
System.out.print("|");
for(int j=0;j<2;j++)
{
System.out.print(" "+matrika[i][j]+" ");
}
System.out.println("|");
}
System.out.println("");
float dtr=(matrika[1][1]*matrika[0][0])-(matrika[1][0]*matrika[0][1]);
System.out.println("Determinannya: "+dtr);
int temp=matrika[0][0];
matrika[0][0]=matrika[1][1];
matrika[1][1]=temp;
matrika[0][1]=matrika[0][1]*-1;
matrika[1][0]= matrika[1][0]*-1;
System.out.println("");
System.out.println("Adjointnya: ");
for(int i=0;i<2;i++)
{
System.out.print("|");
for(int j=0;j<2;j++)
{
System.out.print(" "+matrika[i][j]+" ");
}
System.out.println("|");
}
System.out.println("");
System.out.println("Matrik Inversnya: ");
for(int i=0;i<2;i++)
{
System.out.print("|");
for(int j=0;j<2;j++)
{
System.out.print(" "+matrika[i][j]*(1/dtr)+" ");
}
System.out.println("|");
}
System.out.println("");
}
}
class invers
{
public static void main (String[]args) throws Exception
{
BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
System.out.println("");
System.out.println("=======INVERS=======");
System.out.println("Ordo Matriks = 2 x 2");
int [][]matrika = new int[2][2];
System.out.println("Masukan Elemen Matriksnya:");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
System.out.print("Elemen ["+(i+1)+","+(j+1)+"]: ");
matrika[i][j]=Integer.parseInt(input.readLine());
}
}
System.out.println("");
System.out.println("Matriknya: ");
for(int i=0;i<2;i++)
{
System.out.print("|");
for(int j=0;j<2;j++)
{
System.out.print(" "+matrika[i][j]+" ");
}
System.out.println("|");
}
System.out.println("");
float dtr=(matrika[1][1]*matrika[0][0])-(matrika[1][0]*matrika[0][1]);
System.out.println("Determinannya: "+dtr);
int temp=matrika[0][0];
matrika[0][0]=matrika[1][1];
matrika[1][1]=temp;
matrika[0][1]=matrika[0][1]*-1;
matrika[1][0]= matrika[1][0]*-1;
System.out.println("");
System.out.println("Adjointnya: ");
for(int i=0;i<2;i++)
{
System.out.print("|");
for(int j=0;j<2;j++)
{
System.out.print(" "+matrika[i][j]+" ");
}
System.out.println("|");
}
System.out.println("");
System.out.println("Matrik Inversnya: ");
for(int i=0;i<2;i++)
{
System.out.print("|");
for(int j=0;j<2;j++)
{
System.out.print(" "+matrika[i][j]*(1/dtr)+" ");
}
System.out.println("|");
}
System.out.println("");
}
}
Output
No comments:
Post a Comment