for(k=0;k<2;k++)for(i=k+1;i<3;i++){if (a[k][k]!=0) for(j=k;j<3;j++) a[i][j]=(a[i][j]*a[k][k]-a[k][j]*a[i][k])/a[k][k];}