Program Slar; uses crt; type matr = array [1..10, 1..10] of real; vect = array [1..10] of real; var a: matr; x: vect; n, i, j: integer; Procedure Exchange(i, k: integer); var temp: real; m: integer; begin if i = k then exit; for m := k to n + 1 do begin temp := a[i, m]; a[i, m] := a[k, m]; a[k, m] := temp; end; end; Procedure Gauss(n: integer; a: matr; var x: vect); const e = 0.00000001; var i, j, k, q: integer; sum, max: real; imax: integer; begin for k := 1 to n do begin imax := k; max := abs(a[k, k]); for q := k + 1 to n do begin if abs(a[q, k]) > max then begin max := abs(a[q, k]); imax := q; end; end; end; if abs(max) < e then begin x[1] := 0; exit end else begin Exchange(imax, k); for i := k + 1 to n do begin for j := n + 1 downto k do begin a[i, j] := a[i, j] - a[i, k] / a[k, k] * a[k, j]; end; end; end; for i := 1 to n do begin for j := 1 to n + 1 do begin write('a[', i, ',', j, '] = ', a[i, j]:2:2, ' '); writeln; end; end; {Зворотній хід} x[n] := a[n, n + 1] / a[n, n]; for i := n - 1 downto 1 do begin sum := 0; for k := i + 1 to n do begin sum := sum + x[k] * a[i, k]; a[i, n + 1] := a[i, n + 1] - sum; x[i] := a[i, n + 1] / a[i, i]; end; end; end; begin clrscr; {Читаємо кількість рівнянь} read(n); {Читаємо коефіцієнти рівнянь} for i := 1 to n do begin for j := 1 to n + 1 do begin read(a[i, j]); write('a[', i, ',', j, '] = ', a[i, j]:2:2, ' '); end; writeln; end; writeln; {Викликаємо функцію Гауса} Gauss(n, a, x); if x[1] = 0 then begin writeln('System do not have a solution'); end else begin {Виводимо розв’язки на екран} for i := 1 to n do begin writeln('x[', i, '] = ', x[i]:2:2, ' '); end; end; end.