import java.io.*;

class SCO10C
{

  public static double[] gaussjordan(double a[][],double b[])
  { //pivotsuz
  int n=b.length;	  
  double x[]=new double[n];
  double carpan=0;
  double toplam=0;
  double buyuk;
  double dummy=0;
  int i,j,k,p,ii,jj;
  for(k=0;k<n;k++)
  { //gauss jordan elemeyi çözme
	for(j=k+1;j<n;j++)
	{ a[k][j]/=a[k][k]; }
	  b[k]/=a[k][k];
	a[k][k]=1.0;
	  
    for(i=0;i<n;i++)
    {  if(i!=k)
       {
	      carpan=a[i][k];
          a[i][k]=0;
          for(j=k+1;j<n;j++)
          {   a[i][j]-=carpan*a[k][j]; }
          b[i]   =b[i]   -carpan*b[k];
       }    
	}
  }
  for(i=0;i<n;i++)
  {
    x[i]=b[i];
  }
  return x;
  } 	

  public static double[][] gaussjordan(double a[][])
  { //pivotsuz
  int n=a.length;
  int m=a[0].length;	  
  int o=m-n;
  double x[][]=new double[n][o];
  double carpan=0;
  double toplam=0;
  double buyuk;
  double dummy=0;
  int i,j,k,p,ii,jj;
  for(k=0;k<n;k++)
  { //gauss jordan elemeyi çözme
	for(j=k+1;j<m;j++)
	{ a[k][j]/=a[k][k]; }
	a[k][k]=1.0;	  
    for(i=0;i<n;i++)
    {  if(i!=k)
       {
	      carpan=a[i][k];
          a[i][k]=0;
          for(j=k+1;j<m;j++)
          {   a[i][j]-=carpan*a[k][j]; }
       }    
	}
  }
  for(jj=0;jj<o;jj++)
  {for(i=0;i<n;i++)
   {x[i][jj]=a[i][n+jj];}}
  return x;
  } 	
  
        
  public static void main(String args[]) throws IOException
  {
  double a[][]={{3,-0.1,-0.2},{0.1,7,-0.3},{0.3,-0.2,10}};
  double b[]={7.85,-19.3,71.4};
  double x[]=gaussjordan(a,b);
  Text.print(x,"Gauss Jordan Metodu çözümü");
  }
}