Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program NNNNN1;
- {$APPTYPE CONSOLE}
- {$MAXSTACKSIZE 200000000}
- {$Q+,I+,R+}
- uses
- SysUtils;
- CONST
- eps=0.0001;
- pi=3.1415926535897932384626433832795;
- TYPE
- vect=Array[1..300] of Real;
- t_vect=Array[1..300] of vect;
- VAR iter,iter1,i,j,n,m,i1,j1,n1,m1,k,kk,k1,sh1,sh2,ll : Integer;
- norma,norma1,tau,ro,ro_, first,opt,opt1,ss,tt,ro1,ro_1 : Real;
- r,f,y,p,w,tmp,pr1,pr2,pr3,y1,y2,y3 : T_VECT;
- rr,zz,y12,y11,a33p,am,x,yy,pp,yy1,pq,xx,y4,q:vect;
- {-------------------------------------------------------------------------------}
- FUNCTION scalar(v1,v2: T_VECT;n,m:integer): Real;
- Var res : Real;
- i,j : Integer;
- Begin
- res:=0;
- For i:=1 To n Do
- For j:=1 To m Do
- res:=res + v1[i][j]*v2[i][j];
- scalar:=res;
- End;
- {-------------------------------------------------------------------------------}
- procedure print(a:t_vect;n,m:integer);
- var i,j:integer;
- begin
- for i:=1 to n do begin
- for j:=1 to m do begin
- write(a[i,j]:6:4,' ');end;writeln;end;
- end;
- {-------------------------------------------------------------------------------}
- FUNCTION scalar1(v1,v2: vect;n:integer): Real;
- Var res : Real;
- i,j : Integer;
- Begin
- res:=0;
- For i:=1 To n Do
- res:=res + v1[i]*v2[i];
- scalar1:=res;
- End;
- {-------------------------------------------------------------------------------}
- function minus(a,b:vect;m:integer):vect;
- var i,j,k:integer;
- tmp:real;
- c:vect;
- begin
- FillChar(c,sizeof(c),0);
- for i:=1 to m do
- c[i]:=a[i]-b[i];
- minus:=c;
- end;
- {-------------------------------------------------------------------------------}
- function plus(a,b:vect;m:integer):vect;
- var i,j,k:integer;
- tmp:real;
- c:vect;
- begin
- for i:=1 to m do
- c[i]:=a[i]+b[i];
- plus:=c;
- end;
- {-------------------------------------------------------------------------------}
- function pulti(a:T_VECT;b:vect;m:integer):vect;
- var i,j,k:integer;
- tmp:real;
- c:vect;
- begin
- for i:=1 to m do begin
- tmp:=0;
- for k:=1 to m do begin
- tmp:=tmp+a[i][k]*b[k];
- end;
- c[i]:=tmp;
- end;
- pulti:=c;
- end;
- {-------------------------------------------------------------------------------}
- function pulti1(a:real;b:vect;m:integer):vect;
- var i,j,k:integer;
- c:vect;
- begin
- FillChar(c,sizeof(c),0);
- for i:=1 to m do begin
- c[i]:=a*b[i];
- end;
- pulti1:=c;
- end;
- {-------------------------------------------------------------------------------}
- FUNCTION raz_raz1 (r: T_VECT;n,m:integer): T_VECT;
- Var res,z : T_VECT;
- i,j : Integer;
- Begin
- FillChar(res,sizeof(res),0);
- For i:=1 To n Do Begin
- RES[i,1]:=2*R[i,1];
- If i<>1 Then
- RES[i,1]:=RES[i,1]- 0.5*R[i-1,1];
- If i<>n Then
- RES[i,1]:=RES[i][1] - 0.5*R[i+1,1];
- RES[i,1]:=RES[i][1] - R[i,2];
- End;
- // print(res,n,m);
- //z:=res;
- For i:=1 To n Do Begin
- For j:=2 To m Do Begin
- RES[i,j]:=4*r[i,j];
- If i<>1 Then
- RES[i,j]:=RES[i,j]- r[i-1,j];
- If i<>n Then
- RES[i,j]:=RES[i][j] - r[i+1,j];
- If j<>1 Then
- RES[i,j]:=RES[i][j] - r[i,j-1];
- If j<>m Then
- RES[i,j]:=RES[i][j] - r[i,j+1];
- End;
- End;
- raz_raz1:=RES;
- End;
- {-------------------------------------------------------------------------------}
- FUNCTION GET_TAU1(r: real; p: T_VECT; n,m:integer): Real;
- Var s2 : Real;
- tmp : T_VECT;
- i,j : Integer;
- Begin
- s2:=0;
- FillChar(tmp,sizeof(tmp),0);
- tmp:=raz_raz1(p,n,m);
- For i:=1 To n Do
- For j:=1 To m Do
- s2:=s2 + TMP[i,j]*P[i,j];
- GET_TAU1:=r/s2;
- End;
- {-------------------------------------------------------------------------------}
- FUNCTION SSOR_PRE1(f: T_VECT;n,m:integer): T_VECT;
- Var y,tmp,r,y2 : T_VECT;
- iter,i,j : Integer;
- norma,prev,s,w : Real;
- Begin
- iter:=0;
- norma:=0;
- prev:=0;
- s:=0;
- w:=2/(1+sin(pi/(n)));
- //writeln('w= ',w:4:4);
- FillChar(y,sizeof(y),0);
- FillChar(r,sizeof(r),0);
- FillChar(tmp,sizeof(tmp),0);
- tmp:=raz_raz1(y,n,m);
- For i:=1 To N Do
- For j:=1 To M Do Begin
- R[i,j]:=F[i,j] - TMP[i,j];
- If norma<abs(R[i,j]) Then
- norma:=abs(R[i,j]);
- End;
- For i:=1 To N Do begin
- s:=0;
- Y[i,1]:=(1-w)*Y[i,1];
- If i<>1 Then
- s:=s + 0.5*Y[i-1,1];
- If i<>n Then
- s:=s + 0.5*Y[i+1,1];
- s:=s + Y[i,2];
- s:=s * 0.5*w;
- Y[i,1]:=Y[i][1] + s + 0.5*w*F[i,1];
- //u(i,j) = (1-w)*u(i,j)+0.25*w*(u(i-1,j)+u(i,j-1)+u(i+1,j)+u(i,j+1))+0.25*w*f(i,j);
- End;
- For i:=1 To N Do begin
- For j:=2 To M Do Begin
- s:=0;
- //if j<>1 then
- Y[i,j]:=(1-w)*Y[i,j];
- If i<>1 Then
- s:=s + Y[i-1,j];
- If i<>n Then
- s:=s + Y[i+1,j];
- If j<>1 Then
- s:=s + Y[i,j-1];
- If j<>m Then
- s:=s + Y[i,j+1];
- s:=s * 0.25*w;
- // if j<>1 then
- Y[i,j]:=Y[i][j] + s + 0.25*w*F[i,j];
- //u(i,j) = (1-w)*u(i,j)+0.25*w*(u(i-1,j)+u(i,j-1)+u(i+1,j)+u(i,j+1))+0.25*w*f(i,j);
- End;
- end;
- //obratnii hod
- For i:=n DownTo 1 Do
- For j:=n DownTo 2 Do Begin
- s:=0;
- //if j<>1 then
- Y[i,j]:=(1-w)*Y[i,j];
- If i<>1 Then
- s:=s + Y[i-1,j];
- If i<>n Then
- s:=s + Y[i+1,j];
- If j<>1 Then
- s:=s + Y[i,j-1];
- If j<>m Then
- s:=s + Y[i,j+1];
- s:=s * 0.25*w;
- //if j<>1 then
- Y[i,j]:=Y[i][j] + s + 0.25*w*F[i,j];
- //u(i,j) = (1-w)*u(i,j)+0.25*w*(u(i-1,j)+u(i,j-1)+u(i+1,j)+u(i,j+1))+0.25*w*f(i,j);
- End;
- For i:=n DownTo 1 Do begin
- s:=0;
- Y[i,1]:=(1-w)*Y[i,1];
- If i<>1 Then
- s:=s + 0.5*Y[i-1,1];
- If i<>n Then
- s:=s + 0.5*Y[i+1,1];
- s:=s + Y[i,2];
- s:=s * 0.5*w;
- Y[i,1]:=Y[i][1] + s + 0.5*w*F[i,1];
- //u(i,j) = (1-w)*u(i,j)+0.25*w*(u(i-1,j)+u(i,j-1)+u(i+1,j)+u(i,j+1))+0.25*w*f(i,j);
- End;
- //norma neviazki
- For i:=1 To n Do
- For j:=1 To m Do Begin
- If i<>1 Then
- norma:=norma + Y[i-1,j];
- If i<>n Then
- norma:=norma + Y[i+1,j];
- If j<>1 Then
- norma:=norma + Y[i,j-1];
- If j<>m Then
- norma:=norma + Y[i,j+1];
- norma:=norma - 4*Y[i,j];
- norma:=abs(F[i,j] + norma);
- End;
- SSOR_PRE1:=Y;
- End;
- {-------------------------------------------------------------------------------}
- FUNCTION raz_raz (r: T_VECT;n,m:integer): T_VECT;
- Var res : T_VECT;
- i,j : Integer;
- Begin
- //FillChar(res,sizeof(res),0);
- For i:=1 To n Do Begin
- For j:=1 To m Do Begin
- RES[i,j]:=4*R[i,j];
- If i<>1 Then
- RES[i,j]:=RES[i,j] - R[i-1,j];
- If i<>n Then
- RES[i,j]:=RES[i][j] - R[i+1,j];
- If j<>1 Then
- RES[i,j]:=RES[i][j] - R[i,j-1];
- If j<>m Then
- RES[i,j]:=RES[i][j] - R[i,j+1];
- End;
- End;
- raz_raz:=RES;
- End;
- {-------------------------------------------------------------------------------}
- FUNCTION GET_TAU(r: real; p: T_VECT; n,m:integer): Real;
- Var s2 : Real;
- tmp : T_VECT;
- i,j : Integer;
- Begin
- s2:=0;
- FillChar(tmp,sizeof(tmp),0);
- tmp:=raz_raz(p,n,m);
- For i:=1 To n Do
- For j:=1 To m Do
- s2:=s2 + TMP[i,j]*P[i,j];
- GET_TAU:=r/s2;
- End;
- {-------------------------------------------------------------------------------}
- FUNCTION SSOR_PRE(f: T_VECT;n,m:integer): T_VECT;
- Var y,tmp,r : T_VECT;
- iter,i,j : Integer;
- norma,prev,s,w : Real;
- Begin
- iter:=0;
- norma:=0;
- prev:=0;
- s:=0;
- w:=2/(1+sin(pi/(M+1)));
- //writeln('w= ',w:4:4);
- FillChar(y,sizeof(y),0);
- FillChar(r,sizeof(r),0);
- FillChar(tmp,sizeof(tmp),0);
- tmp:=raz_raz(y,n,m);
- For i:=1 To N Do
- For j:=1 To M Do Begin
- R[i,j]:=F[i,j] - TMP[i,j];
- If norma<abs(R[i,j]) Then
- norma:=abs(R[i,j]);
- End;
- For i:=1 To N Do
- For j:=1 To M Do Begin
- s:=0;
- Y[i,j]:=(1-w)*Y[i,j];
- If i<>1 Then
- s:=s + Y[i-1,j];
- If i<>n Then
- s:=s + Y[i+1,j];
- If j<>1 Then
- s:=s + Y[i,j-1];
- If j<>m Then
- s:=s + Y[i,j+1];
- s:=s * 0.25*w;
- Y[i,j]:=Y[i][j] + s + 0.25*w*F[i,j];
- //u(i,j) = (1-w)*u(i,j)+0.25*w*(u(i-1,j)+u(i,j-1)+u(i+1,j)+u(i,j+1))+0.25*w*f(i,j);
- End;
- //obratnii hod
- For i:=n DownTo 1 Do
- For j:=n DownTo 1 Do Begin
- s:=0;
- Y[i,j]:=(1-w)*Y[i,j];
- If i<>1 Then
- s:=s + Y[i-1,j];
- If i<>n Then
- s:=s + Y[i+1,j];
- If j<>1 Then
- s:=s + Y[i,j-1];
- If j<>m Then
- s:=s + Y[i,j+1];
- s:=s * 0.25*w;
- Y[i,j]:=Y[i][j] + s + 0.25*w*F[i,j];
- //u(i,j) = (1-w)*u(i,j)+0.25*w*(u(i-1,j)+u(i,j-1)+u(i+1,j)+u(i,j+1))+0.25*w*f(i,j);
- End;
- //norma neviazki
- For i:=1 To n Do
- For j:=1 To m Do Begin
- If i<>1 Then
- norma:=norma + Y[i-1,j];
- If i<>n Then
- norma:=norma + Y[i+1,j];
- If j<>1 Then
- norma:=norma + Y[i,j-1];
- If j<>m Then
- norma:=norma + Y[i,j+1];
- norma:=norma - 4*Y[i,j];
- norma:=abs(F[i,j] + norma);
- End;
- SSOR_PRE:=Y;
- End;
- {-------------------------------------------------------------------------------}
- function A33(a,b:integer):T_VECT;
- var
- i,j:integer;
- q:T_VECT;
- begin
- for i:=1 to a do begin
- for j:=1 to b do begin
- if i=j then q[i,j]:=4
- else if (i+1=j) or (i=j+1) then q[i,j]:=-1
- else q[i,j]:=0;
- end;end;
- { for i:=1 to a do begin
- for j:=1 to b do begin
- write(q[i,j]:6:1,' ');
- end; writeln; end; }
- A33:=q;
- end;
- {-------------------------------------------------------------------------------}
- procedure Grad0(n,m:integer;r:T_VECT);
- BEGIN
- //FillChar(r,sizeof(r),16);
- // FillChar(F,sizeof(F),16);
- //FillChar(y,sizeof(y),0);
- //FillChar(p,sizeof(p),0);
- //FillChar(w,sizeof(w),0);
- // FillChar(tmp,sizeof(tmp),0);
- iter:=0;
- //norma:=eps+1;
- tau:=0;
- ro:=0;
- ro_:=0;
- For i:=1 To n Do begin
- For j:=1 To m Do Begin
- //F[i][j]:=16;
- //R[i][j]:=16;
- Y[i][j]:=0;
- P[i][j]:=0;
- W[i][j]:=0;
- tmp[i][j]:=0;
- End;end;
- //f:=r;
- p:=ssor_pre1(r,n,m);
- ro:=scalar(p,r,n,m);
- While true Do Begin
- INC(iter);
- norma:=0;
- tau:=get_tau1(ro,p,n,m);
- // writeln('--------------tau---------------');
- // writeln('tau= ',tau);
- For i:=1 To n Do
- For j:=1 To m Do
- Y[i,j]:=Y[i][j] + tau*P[i,j];
- // writeln('--------------x---------------');
- //print(y,n,m);
- tmp:=raz_raz1(p,n,m);
- For i:=1 To n Do
- For j:=1 To m Do Begin
- r[i,j]:=r[i][j] - tau*TMP[i,j];
- norma:=norma+abs(r[i,j]);
- // If norma<abs(r[i,j]) Then
- // norma:= abs(r[i,j]);
- End;
- //writeln('--------------r---------------');
- //print(r,n,m);
- if iter=1 then first:=norma;
- //writeln('norma_next=',norma:6:3,' norma1=',first:6:3, ' ');
- if abs(norma/first)<eps then break;
- w:=ssor_pre1(r,n,m); //pereschet po formyle
- //writeln('w= ',w[1,1]);
- ro_:=ro;
- ro:=scalar(w,r,n,m);
- For i:=1 To n Do
- For j:=1 To m Do
- P[i,j]:=W[i,j] + (ro/ro_)*P[i,j];
- // writeln('--------------p---------------');
- // print(p,n,m);
- End;
- for i:=1 to n do begin
- for j:=1 to m do
- if j=1 then
- y4[i]:=y[i,j];
- end;
- end;
- {-------------------------------------------------------------------------------}
- procedure Grad(n,m:integer;r:T_VECT);
- BEGIN
- //FillChar(r,sizeof(r),16);
- // FillChar(F,sizeof(F),16);
- //FillChar(y,sizeof(y),0);
- //FillChar(p,sizeof(p),0);
- //FillChar(w,sizeof(w),0);
- // FillChar(tmp,sizeof(tmp),0);
- iter:=0;
- norma:=eps+1;
- tau:=0;
- ro:=0;
- ro_:=0;
- For i:=1 To n Do begin
- For j:=1 To m Do Begin
- //F[i][j]:=16;
- //R[i][j]:=16;
- Y[i][j]:=0;
- P[i][j]:=0;
- W[i][j]:=0;
- tmp[i][j]:=0;
- End;end;
- //f:=r;
- p:=ssor_pre(r,n,m);
- ro:=scalar(p,r,n,m);
- While true Do Begin
- INC(iter);
- norma:=0;
- tau:=get_tau(ro,p,n,m);
- //writeln('tau= ',tau);
- For i:=1 To n Do
- For j:=1 To m Do
- Y[i,j]:=Y[i][j] + tau*P[i,j];
- tmp:=raz_raz(p,n,m);
- For i:=1 To n Do
- For j:=1 To m Do Begin
- r[i,j]:=r[i][j] - tau*TMP[i,j];
- norma:=norma+abs(r[i,j]);
- // If norma<abs(r[i,j]) Then
- // norma:= abs(r[i,j]);
- End;
- if iter=1 then first:=norma;
- if norma/first<eps then break;
- w:=ssor_pre(r,n,m); //pereschet po formyle
- //writeln('w= ',w[1,1]);
- ro_:=ro;
- ro:=scalar(w,r,n,m);
- For i:=1 To n Do
- For j:=1 To m Do
- P[i,j]:=W[i,j] + (ro/ro_)*P[i,j];
- End;
- { WriteLn('Gradient method with predobusl: ',iter);
- For i:=0 To N-1 Do Begin
- For j:=0 To M-1 Do
- write(Y[i][j]:6:2,' ');
- WriteLn;
- End;}
- end;
- {-------------------------------------------------------------------------------}
- //òóò íà ëèíèè ñöåïëåíèÿ
- procedure nev(n,k,bb,m:integer;z:T_VECT);
- var
- i,l,i1:integer;
- sh:T_VECT;
- begin
- Grad(n,k,z);
- sh:=y;
- if(bb=1) then begin
- l:=1;
- for i:=m to n do begin
- zz[l]:=sh[i,n];l:=l+1;//k:=k+1;
- end; end //end;//end;end;
- else if (bb=2) then begin
- l:=1;
- for i1:=1 to n do begin
- zz[l]:=sh[i1,1];l:=l+1;
- end;end
- else write('ne pravilno vveli bb');
- end;
- {-------------------------------------------------------------------------------}
- //òóò íàõîäèì am
- procedure naxod_am(k,n,n1,m,m1:integer;rr,pq:vect);
- var
- i,j,i1,j1,ll:integer;
- begin
- //---------------------------------------------------------------
- // writeln('-------------1------------');writeln;
- ll:=k;
- for i:=1 to n do begin
- for j:=1 to m do begin
- if(i=ll)and(j=m) then begin
- pr1[i,j]:=pq[ll-k+1];
- ll:=ll+1;
- end
- else pr1[i,j]:=0;
- end;end;
- nev(n,m,1,k,pr1);
- y11:=zz;
- //for i1:=1 to n1 do
- //writeln(y11[i1]:2:4,' ');
- //writeln;
- //writeln('-------------2------------');writeln;
- sh2:=1;
- //for ll:=1 to n1 do begin
- //sh2:=sh2+1;
- for i:=1 to n1 do begin
- for j:=1 to m1 do begin
- if (j=1) then begin
- pr2[i,j]:=pq[sh2];
- sh2:=sh2+1;
- end
- else pr2[i,j]:=0;end;end;
- nev(n1,m1,2,k,pr2);
- y12:=zz;
- //for i1:=1 to n1 do
- //writeln(y12[i1]:2:4,' ');
- //Writeln('------------------A33*p--------------------------');
- a33p:=pulti(A33(n1,m1),pq,n1);
- //for i:=1 to n1 do
- //Writeln(a33p[i]:6:2,' ');
- //Writeln('------------------A33*p-2*p-3*p--------------------------');
- am:=minus(a33p,plus(y11,y12,n1),n1);
- //for i:=1 to n1 do
- //Writeln(am[i]:6:2,' '); Writeln;//am=sp
- //-----------------------------------------------------------------------
- end;
- {-------------------------------------------------------------------------------}
- procedure Grad2(k,n,n1,m,m1:integer;rr:vect);
- var
- iter:integer;
- x:vect;
- begin
- iter:=0;
- norma1:=0;
- FillChar(x,sizeof(x),0);
- kk:=1;
- // ïðàâà ÷àñòü ìàëîãî
- for j1:=1 to m1+1 do begin
- for i1:=1 to n1 do begin
- if (j1=1) then begin
- pr3[i1,j1]:=rr[kk];
- kk:=kk+1;
- end
- else pr3[i1,j1]:=0;
- end;
- end;
- Grad0(n1,m1+1,pr3);
- pq:=y4;
- ro1:=scalar1(pq,rr,n1);
- writeln('-----------------');
- for i:=1 to n1 do
- writeln(pq[i]:6:4,' ');
- writeln('-----------------');
- writeln('ro= ',ro:6:6,' ');
- //while iter>0 do begin
- While true Do Begin
- //iter:=iter-1;
- inc(iter);
- writeln('---------------------------------------------------- ');
- writeln('íîìåð èòåðàöèè:',iter);
- naxod_am(k,n,n1,m,m1,rr,pq);
- Writeln('------------------a_m--------------------------');
- for i:=1 to n1 do
- writeln(am[i]:6:5,' ');
- writeln('---------------------------------------------------- ');
- tt:=scalar1(am,pq,n1);
- writeln('ro=',ro1:6:10,' ');
- writeln('scalar1(am,pq,n1)=',tt:6:2,' ');
- opt:=ro1/tt;
- writeln('lamda opt=',opt:6:10,' ');
- Writeln('------------------x_m+1--------------------------');
- yy1:=pulti1(opt,pq,n1);
- x:=plus(x,yy1,n1);
- for i:=1 to n1 do
- writeln(x[i]:6:10,' ');writeln;
- Writeln('------------------r_m+1--------------------------');
- rr:=minus(rr,pulti1(opt,am,n1),n1);
- if iter=1 then begin
- For i:=1 To N Do
- norma1:=norma1+abs(rr[i]);
- end;
- for i:=1 to n1 do
- writeln(rr[i]:6:6,' ');writeln;
- norma:=0;
- For i:=1 To N Do
- norma:=norma+abs(rr[i]);
- ss:=abs(norma/norma1);
- writeln('----------óñëîâèå âûõîà:abs(norma/norma1)<eps--------------');
- writeln(ss:6:10,' < ',eps:6:6);
- If ss<eps Then
- break;
- kk:=1;
- // ïðàâà ÷àñòü ìàëîãî
- for j1:=1 to m1+1 do begin
- for i1:=1 to n1 do begin
- if (j1=1) then begin
- pr3[i1,j1]:=rr[kk];
- kk:=kk+1;
- end
- else pr3[i1,j1]:=0;
- end;
- end;
- Grad0(n1,m1+1,pr3);
- q:=y4;
- ro_1:=ro1;
- ro1:=scalar1(q,rr,n1);
- opt1:=ro1/ro_1;
- pq:=plus(q,pulti1(opt1,pq,n1),n1);
- Writeln('------------------p_m+1--------------------------');
- for i:=1 to n1 do
- writeln(pq[i]:6:6,' ');
- //writeln('---------------------------------------------------- ');
- end;
- xx:=x;
- iter1:=iter;
- writeln('opa');
- end;
- {-------------------------------------------------------------------------------}
- procedure Grad3(n,m,n1,m1:integer;pr1,pr2:T_vect);
- begin
- Grad(n,m,pr1);
- y1:=y;
- WriteLn('----------------Ðåøåíèå 1 îáëàñòè------------- ');WriteLn;
- For i:=1 To n Do Begin
- For j:=1 To m Do
- write(y1[i][j]:6:2,' ');
- WriteLn;
- End;
- WriteLn;
- Grad(n1,m1,pr2);
- y2:=y;
- WriteLn('----------------Ðåøåíèå 2 îáëàñòè------------- ');WriteLn;
- For i:=1 To n1 Do Begin
- For j:=1 To m1 Do
- write(y2[i][j]:6:2,' ');
- WriteLn;
- End;
- end;
- {-------------------------------------------------------------------------------}
- begin
- assign(output,'output.txt');
- rewrite(output);
- n:=7; m:=7; // ðàçìåð áîëüøîãî êâàäðàòà
- n1:=3; m1:=3; // ðàçìåð ìåíüøåãî
- k:=n-n1+1; k1:=k+n1-1; // ê - ñ êàêîé ñòðîêè ...
- //k:=5;
- for i:=1 to n do
- for j:=1 to m do
- pr1[i,j]:=16; // ïðàâàÿ ÷àñòü áîëüøîãî
- for i1:=1 to n1 do
- for j1:=1 to m1 do
- pr2[i1,j1]:=16; // ïðàâà ÷àñòü ìàëîãî
- Grad3(n,m,n1,m1,pr1,pr2);
- writeln('-------------íåâÿçêà íà ëèíèè ñöåïëåíèÿ------------');writeln;
- for i:=1 to n1 do begin
- rr[i]:=y2[i][1]+y1[k+i-1][n]+16;
- writeln(rr[i]:6:6,' ');
- end;
- Grad2(k,n,n1,m,m1,rr);
- writeln('---------Íàø âåêòîð çà ',iter1,' èòåðàöèé--------------');
- for i:=1 to n1 do
- writeln(xx[i]:6:4,' '); writeln;
- ll:=k;
- for i:=1 to n do begin
- for j:=1 to n do begin
- if(i=ll)and(j=n) then begin
- pr1[i,j]:=xx[ll-k+1]+16;
- ll:=ll+1;
- end
- else pr1[i,j]:=16;
- end;end;
- sh2:=1;
- //for ll:=1 to n1 do begin
- //sh2:=sh2+1;
- for i:=1 to n1 do begin
- for j:=1 to n1 do begin
- if (j=1) then begin
- pr2[i,j]:=xx[sh2]+16;
- sh2:=sh2+1;
- end
- else pr2[i,j]:=16;end;end;
- Grad3(n,m,n1,m1,pr1,pr2); writeln;
- writeln('-------------Ðåøåíèå çàäà÷è------------'); writeln;
- for i:=1 to n do begin
- for j:=1 to n+n1+1 do begin
- if (j<=n) then
- write(y1[i][j]:6:2,' ')
- else if (i>=k)and(i<=k+n1-1) and(j=n+1) then
- write(xx[i-k+1]:6:2,' ')
- else if (i>=k)and(i<=k+n1-1)and (j>n+1)and(j<=n+n1+1) then
- write(y2[i-k+1][j-n-1]:3:2,' ')
- else write(' ')
- end;writeln;end;
- END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement