import java.io.*;

class SCO10C
{

  public static double[] gaussjordan(double a[][],double b[])
  { //pivotsuz
  int n=b.length;
  int np1=n+1;
  double C[][]=new double[n][np1];
  double x[]=new double[n];
  double carpan=0;
  int i,j,k;
  
  for(i=0;i<n;i++)
  {for(j=0;j<n;j++){C[i][j]=a[i][j];};C[i][n]=b[i];}

  for(k=0;k<n;k++)
  { 
	//gauss jordan eleme
	for(j=k+1;j<np1;j++)
	{ C[k][j]/=C[k][k]; }
	for(i=0;i<n;i++)
    {  if(i!=k)
       {  carpan=C[i][k];
          C[i][k]=0;
          for(j=k+1;j<np1;j++)
          {   C[i][j]-=carpan*C[k][j]; }
       }    
	}
  }
  for(i=0;i<n;i++)
  {x[i]=C[i][n];}
  return x;
  } 	
      
  public static void main(String args[]) throws IOException
  {
double a[][]={{3,1,-1},{1,4,1},{2,1,2}};
double b[]={2,12,10};
  double x[]=gaussjordan(a,b);
  Text.print(x,"Gauss Jordan Metodu çözümü");
  }
}