Скачиваний:
329
Добавлен:
04.03.2014
Размер:
4 Кб
Скачать
PROGRAM SLAU;
   uses crt;
   type
      mas=array [0..10] of real;
   var
      i,j,n,flag,z,k,l:integer;
      a,b,c,d,as,bs,x:mas;
      alfa,beta:real;
   label 11,12,13;
   procedure pr(n:integer;a,b,c,d:mas;var AS,BS,x:mas;
                var flag,z:integer;var alfa,beta:real);
      label 1,2,3;
      const eps=0.000001;
      var
         i,t:integer;
         e:real;
   begin
   {***** pr.prog. *****}
      flag:=0;z:=n-1;
      if abs(b[1])>=eps then
      begin
         as[1]:=-c[1]/b[1];
         bs[1]:=d[1]/b[1];
      end else goto 1;
      t:=0;
      for i:=2 to z do
      begin
         e:=a[i]*as[i-1]+b[i];
         if abs(e)>=eps then
         begin
            as[i]:=-c[i]/e;
            bs[i]:=(d[i]-a[i]*bs[i-1])/e;
         end else begin z:=i;t:=1;end;
      end;
      if t<>0 then goto 1;
   {***** obr.prog. *****}
      alfa:=a[n]*as[n-1]+b[n];
      beta:=d[n]-a[n]*bs[n-1];
      if abs(alfa)<eps then goto 2;
      x[n]:=beta/alfa;
      for i:=n-1 downto 1 do
      begin
         x[i]:=as[i]*x[i+1]+bs[i];
      end;goto 3;
      1:begin flag:=1;z:=1;goto 3;end;
      2:begin if abs(beta)<eps then flag:=2 else flag:=3;goto 3;end;
      3:
   {***** kon.prog. *****}
   end;
   function ne(i:integer):real;
   begin
      ne:=a[i]*x[i-1]+b[i]*x[i]+c[i]*x[i+1]-d[i];
   end;
Begin
   textbackground(blue);
   clrscr;
   textcolor(white);
   writeln('   ђ……Ќ€… ’ђ…•„€ЂѓЋЌЂ‹њЌЋ‰   ‘ ‹ Ђ “   Њ…’Ћ„ЋЊ ЏђЋѓЋЌЉ€');
   textcolor(yellow);
   write('ўўҐ¤ЁвҐ а §¬Ґа ¬ ваЁжл (1 <= n <= 10)   ');
   {repeat}
      readln(n);


      {if (n<1)or(n>10) then write('   Ўг¤вҐ ў­Ё¬ вҐ«м­Ґ©   ');
   until (n>=1)and(n<=10);}
   writeln('ўўҐ¤ЁвҐ ¬ ваЁжг');
   k:=4;l:=5;
   if n=1 then begin
   gotoxy(l,k);read(b[1]);l:=l+5;
   gotoxy(l,k);write('|');l:=l+5;
   gotoxy(l,k);read(d[1]);
   goto 11;end;
   for j:=1 to n do
   begin
      if j=1 then
      begin
         gotoxy(l,k);read(b[j]);l:=l+5;
         gotoxy(l,k);read(c[j]);l:=l+5;
         for i:=3 to n do
         begin
            gotoxy(l,k);
            write(0);l:=l+5;
         end;
         gotoxy(l,k);write('|');l:=l+5;
         gotoxy(l,k);read(d[1]);
      l:=5;k:=k+1;
      end;
      if j=n then
      begin
         for i:=1 to n-2 do
         begin
            gotoxy(l,k);
            write(0);l:=l+5;
         end;
         gotoxy(l,k);
         read(a[j]);l:=l+5;
         gotoxy(l,k);read(b[j]);l:=l+5;
         gotoxy(l,k);write('|');l:=l+5;
         gotoxy(l,k);readln(d[j]);
      end;
      if (j>1) and (j<n) then
      begin
         for i:=1 to j-2 do
         begin
            gotoxy(l,k);write(0);l:=l+5;
         end;
         gotoxy(l,k);read(a[j]);l:=l+5;
         gotoxy(l,k);read(b[j]);l:=l+5;
         gotoxy(l,k);read(c[j]);l:=l+5;
         for i:=j+2 to n do
         begin
            gotoxy(l,k);
            write(0);l:=l+5;
         end;
         gotoxy(l,k);write('|');l:=l+5;
         gotoxy(l,k);read(d[j]);
         l:=5;k:=k+1;
      end;
   end;
   textcolor(white);
   writeln('१г«мв в');
   pr(n,a,b,c,d,as,bs,x,flag,z,alfa,beta);
   writeln('   AS      |      BS');
   for i:=1 to z do
      writeln(as[i]:10:6,'  |  ',bs[i]:10:6);
   if flag=0 then
   begin
      writeln('     X             ­Ґгўп§Є ');
      a[1]:=0;x[0]:=0;x[n+1]:=0;c[n]:=0;
      for i:=1 to n do
         writeln(x[i]:10:6,'     ',ne(i):16);
   end
   else
   12:case flag of
      1:writeln('бЁб⥬  ­Ґ Ё¬ҐҐв аҐиҐ­Ё© ¬Ґв®¤®¬ Їа®Ј®­ЄЁ');
      2:writeln('бЁб⥬  Ё¬ҐҐв ЎҐбЄ®­Ґз­® ¬­®Ј® аҐиҐ­Ё©');
      3:writeln('бЁб⥬  ­Ґб®ў¬Ґбв­ ');
   end;if n=1 then goto 13;
   if flag<>1 then writeln('alfa = ',alfa:7:2,'    beta = ',beta:7:2);
   goto 13;
   11:if b[1]=0 then
      begin
         if d[1]=0 then begin flag:=2;goto 12;end;
         if d[1]<>0 then begin flag:=3;goto 12;end;
      end;
     x[1]:=d[1]/b[1];
     writeln;textcolor(white);
     writeln('१г«мв в');
     writeln('x[1] = ',x[1]:8:3);

   13:
   repeat until keypressed;

End.
Соседние файлы в папке Alex