#include #include #include /* * MUST BE COMPILED with -lm */ void print( int n, double a[10][10], double b[10] ) /* print the augmented array */ { int i,j; for ( i=0; i runningmax ) { p = r; runningmax = temp; } } /* either p == -1 or p>=k indexes a * row such that u[p][j] is a pivot element */ if ( p >= 0 ) { swap (n, u, y, p, k ); s = 1/u[k][j]; for ( ell =k+1; ell < n; ++ ell ) /* subtract u[ell][j] times row k ... */ subtract (n, u, y,k, u[ell][j] * s, ell ); ++k; } } } void back_substitute ( int n, double u[10][10], double y[10], double x[10]) { /* TO BE FILLED IN */ } main() { double a[10][10], u[10][10]; double b[10], y[10], x[10]; int n, w; /* Fill in code here to scan in a and b together * from input in the form of an augmented matrix such as * 2 3 * 1 2 3 * 4 5 6 * * n=2 w=3 (n rows and w columns. Expect w = n+1) * a[0][0]=1 a[0][1]=2 b[0]=3 etcetera */ printf ("Input matrix\n"); print( n, a, b ); reduce ( n, a, b, u, y ); printf ("Reduced matrix\n"); print( n, u, y); back_substitute(n, u, y, x); print_answer(n, x); }