Текст программы

Текст программы. include stdio.h include conio.h include math.h include stdlib.h void Readstrchar s, int max reads a string int c whilec getchar n ifmax 1 s c, max ifmax 0 s 0 void ReadMatrixint flag, double a, double c, int sz reads the matrix FILE f the matrix file int i, j ifflag 1 if that file exists f fopenmatrix.txt, rt opens file on reding and check its existence iff NULL if file dont exist printfNo file is found. n return int ch fori0 i sz i reads the matrix A and the free elements matrix from the file forj0 j sz1 j ifch fgetcf EOF j sz fscanff, lf, aisz j else ifj sz fscanff, lf, ci fclosef closes the file else ifflag 2 if you enter a matrix yourself fori0 i sz i reads the matrix A forj0 j sz j printfEnter an Aii element, i, j scanflf, aisz j forj0 j sz j reads free elements printfnEnter an bi element, j scanflf, cj bool CheckIIdouble x, double prev, int sz, double acc, double q, double r, double e, double f checking roots by xk - xk-1 acc double n 0 double w int i, j forj0 j sz j iffabsxj - prevj acc n ifn0 xk - xk-1 q fabsx0 - prev0 fori1 i sz i w fabsxi - previ ifw q q w e r - f fxk - fxk-1 ifn return false else return true double MPSdouble a, double c, double x, int sz, double acc, int p, double q, double e minimizes function f double prev, g,f, z,r double l 0.7 the first value of step int i, j,k, t,y prev new doublesz fori0 i sz i forj0 j sz j aisz j aisz j2 12A z 0 y0 fori0 i sz i f 12 Ax, x b, x g 0 forj0 j sz j g aisz jxj g gxi z g cixi do makes and count iterations yo fork0 k sz k prevk xk saves previous iteration results t 0 fork0 k sz k xk - l fxk-1 - le f 0 fori0 i sz i g 0 forj0 j sz j g aisz jxj g gxi f g cixi iff z fxk-1 - le fxk-1 xk 2l fxk-1 le f 0 fori0 i sz i g 0 forj0 j sz j g aisz jxj g gxi f g cixi iff z fxk-1 le fxk-1 xk prevk t else fxk-1 le fxk-1 r z z f saves previous value of function f else fxk-1 - le fxk-1 r z z f saves previous value of function f iftsz l l2 the step subdivision goto yo p a number of steps whileCheckIIx, prev, sz, acc, q,r, e,f xk - xk-1 acc return f delete prev void mainvoid double a, x, c, acc presents arrays and an accuracy double f, q,e int p, sz presents the size of your matrix and the number of iterations int h, i printfEnter the size of your matrix asks for the size of your matrix scanfi, sz printfEnter an accuracy asks for an accuracy scanflf, acc a new doubleszsz c new doublesz x new doublesz do asks your wish about the entering your matrix printfPress 1 if you want to read your matrix from the file matrix.txtn printfPress 2 if you want to enter your matrix yourselfn scanfi, h ReadstrNULL, 0 whileh 1 h 2 fori0 i sz i the first approximation printfEnter the first approximation xi, i scanflf, xi ReadMatrixh, a, c, sz reads the matrix p0 q0 e0 f MPSa, c,x, sz, acc, p,q, e fori0 i sz i shows need roots by 10-numeral accuracy printfnxi .10lf, i, xi printfnf .10lf, f shows value of function f printfnnnThe number of steps in, p shows the number of steps we need printfnxk - xk-1 .10lfn, q shows xk - xk-1 printfnfxk - fxk-1 .10lfn, e shows fxk - fxk-1 delete a delete c delete x