Составление простейших программ с использованием процедур пользователя, страница 3

end;

end;

procedure vvod_m(var c:matr;m,n:integer);

var i,j:integer;

begin

for i:=1 to m do

for j:=1 to n do

read (f,c[i,j]);

end;

procedure vyvod_m(var c:matr;m,n:integer;nameMatr:stroka);

var

i,j:integer;

begin

writeln ('eto matrica ',nameMatr);

writeln (fout,'eto matrica ',nameMatr);

for i:=1 to m do begin

for j:=1 to n do begin

write(fout,c[i,j]:6:2,' ');

write(c[i,j]:6:2,' ')

end;

end;

writeln;

writeln(fout);

end;

procedure vyvod_v(x:vect;n:integer);

var i:integer;

begin

writeln;

for i:=1 to n do

writeln (x[i]:8:4);writeln

end;

begin

writeln('vvedite imia faila dlia vvoda ishodnih matric,');

writeln ('   "laba7.txt" ');

write('(fail dolgen bit sozdan do vipolneniia programmi):');

readln(NameFile);

assign(f,NameFile);

reset(f);

writeln ('vvedite imia faila dlia vivoda');

writeln('naprimer,laba7.txt; printer-prn;ne vivodit - nul');

readln (NameFileOut);

assign (fout,NameFileOut);

rewrite(fout);

vvod_m(a,2,3);

vyvod_m(a,2,3,' ishodnaia a');

vvod_m (b,2,2);

vyvod_m(b,2,2,' ishodnaia b');

mult (a,2,3,x);

vyvod_v(x,2);

mult (b,2,2,y);

vyvod_v(y,2);

close(f);

close(fout);

end.

Решение

G:\TP\BIN>tpx.exe

Turbo Pascal  Version 7.0  Copyright (c) 1983,92 Borland International

vvedite imia faila dlia vvoda ishodnih matric,

   "laba7.txt"

(fail dolgen bit sozdan do vipolneniia programmi):f:\Azimov\7. pas

vvedite imia faila dlia vivoda

naprimer,laba7.txt; printer-prn;ne vivodit - nul

nul

eto matrica  ishodnaia a

  0.10  -0.10   0.50   0.20  -0.20   0.70

eto matrica  ishodnaia b

 -1.00   0.10  -0.10   2.00

  0.5000

  1.2000

 -0.9000

  1.0000