#include<stdio.h>
#include<math.h>
void
show( float a[ 100 ] [ 100 ] , int n, int m)
{
int i, j;
for ( i= 0 ; i< n; i++ )
{
for ( j= 0 ; j< m; j++ )
{
}
}
}
int
main( )
{
float a[ 100 ] [ 100 ] ;
float t, a1[ 100 ] , sum= 0 ;
int p, r, c, n, m, k;
int bool= 1 ;
float x;
int i, j;
for ( i= 0 ; i< n; i++ )
{
for ( j= 0 ; j< m; j++ )
{
}
}
p= 0 ;
for ( i= 0 ; i< n; i++ )
{
bool= 1 ;
for ( j= 0 ; j< m; j++ )
{
if ( a[ i] [ j] != 0 )
{
bool= 0 ;
break ;
}
}
if ( bool== 1 )
{
for ( k= 0 ; k< m; k++ )
{
t= a[ n] [ k] ;
a[ n] [ k] = a[ i] [ k] ;
a[ i] [ k] = t;
}
n--;
}
}
while ( p< n&& p< m)
{
jump:
r= 1 ;
while ( a[ p] [ p] == 0 )
{
if ( p+ r> n- 1 )
{
p= p+ 1 ;
goto jump;
}
for ( c= 0 ; c< m; c++ )
{
t= a[ p+ r] [ c] ;
a[ p+ r] [ c] = a[ r] [ c] ;
a[ r] [ c] = t;
}
r= r+ 1 ;
}
for ( r= 1 ; r< n- p; r++ )
{
x= ( a[ p+ r] [ p] ) / a[ p] [ p] ;
if ( a[ p+ r] [ p] != 0 )
{
for ( c= 0 ; c< m; c++ )
{
a[ p+ r] [ c] = ( a[ p] [ c] * x) - a[ p+ r] [ c] ;
}
}
}
p++;
}
show( a, n, m) ;
for ( i= 0 ; i< 100 ; i++ )
{
a1[ i] = ( float ) 1 ;
}
for ( i= n- 1 ; i>= 0 ; i-- )
{
sum= 0 ;
for ( j= m- 2 ; j> i; j-- )
{
sum+= a1[ j] * a[ i] [ j] ;
}
if ( i< n- 1 )
{
a[ i] [ m- 1 ] = a[ i] [ m- 1 ] - sum;
}
if ( i== n- 1 )
{
sum+= a1[ j] * a[ i] [ j] ;
}
a1[ i] = a[ i] [ m- 1 ] / a[ i] [ j] ;
}
for ( i= 0 ; i<=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gkJCWdldGNoYXIoKTsKCXJldHVybiAwOwp9Cg==
compilation info
prog.c: In function ‘main’:
prog.c:26: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:31: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
stdout
3.000000 4.000000 1.000000 6.000000
0.000000 3.666667 -1.333333 9.000000
-0.000000 0.000000 -0.727273 2.909091
1st variable is 2.000000
2st variable is 1.000000
3st variable is -4.000000