import java.io.*;

class NA14A
{
  public static double determinant(double a[][])
  {
  int n=a.length;	  
  double x[]=new double[n];
  double carpan=0;
  double toplam=0;
  //gauss eleme
  int i,j,k;
  System.out.println("Original matrix :\n"+Matrix.toString(a));
  for(k=0;k<(n-1);k++)
  {
    for(i=k+1;i<n;i++)
    {  carpan=a[i][k]/a[k][k];
       a[i][k]=0;
       for(j=k+1;j<n;j++)
       {   a[i][j]-=carpan*a[k][j]; }          
	}
  }
  double mult=1.0;
  for(i=0;i<n;i++)
  {mult*=a[i][i];}
  return mult;
  }
    
    
  public static void main(String args[]) throws IOException
  {
  double a[][]={{1,2,5},{2,1,2},{3,1,1}};
  double det=determinant(a);
  System.out.println("det ="+det);
  }
}