Научная работа

PASCAL:Задача решения системы уравнений методом итерации
Богданова М.В.

program m_iter_sys;

Uses Crt;

label 1,2;
const n=4;e=0.001;
var i,j,k,t:integer;
sum1:real;
f:boolean;
a,c:array [1..n,1..n] of real;
s1,x,x0,d,b:array [1..n] of real;

begin
ClrScr;
for i:=1 to n do
begin
writeln ('введите коэффициенты в ',i,' строке');
for j:=1 to n do
readln (a[i,j]);
end;
writeln;
writeln ('введите свободные члены');
for i:=1 to n do
readln (b[i]);
ClrScr;
for i:=1 to n do
for j:=1 to n do
begin
if i=j then c[i,j]:=0
else c[i,j]:=-a[i,j]/a[i,i];
end;
for i:=1 to n do
d[i]:=b[i]/a[i,i];
{проверка сходимости}
for i:=1 to n do
begin
sum1:=0;
for j:=1 to n do
sum1:=sum1+c[i,j];
s1[i]:=sum1;
end;
sum1:=s1[1];
for i:=2 to n do
if s1[i]>sum1 then sum1:=s1[i];
if abs(sum1)<1 then begin
{конец проверки}
for i:=1 to n do
x0[i]:=d[i];
for i:=1 to n do
begin
x[i]:=0;
for j:=1 to n do
x[i]:=x[i]+c[i,j]*x0[j];
end;
for i:=1 to n do
x[i]:=x[i]+d[i];
1: begin
for i:=1 to n do
x0[i]:=x[i];

for i:=1 to n do
begin
x[i]:=0;
for j:=1 to n do
x[i]:=x[i]+c[i,j]*x0[j];
end;
for i:=1 to n do
x[i]:=x[i]+d[i];
t:=0;
for i:=1 to n do
if abs(x[i]-x0[i])<e then t:=t+1;
if t=n then goto 2 else goto 1
end;
2: writeln ('Ответ:');
for i:=1 to n do
write (x[i]:2:2,' ');
writeln;
end
else writeln ('система не сходится');
readln
end.