Обсуждение:Лабораторная работа №7 Инициализация и использование в программах текстовых файлов
program projekt1;
{$APPTYPE CONSOLE}
uses
SysUtils,uCRT;
const m=5;n=6; var A:array[1..m,1..n] of integer;i,j:integer;f:text; S:array[1..n] of real; begin for i:=1 to m do begin for j:=1 to n do begin randomize; a[i,j]:=random(100); write(a[i,j],' '); s[j]:= end; writeln; end; assign(f,'File.txt'); rewrite(f); for i:=1 to m do begin for j:=1 to n do begin write(f,a[i,j],' '); end; writeln(f); writeln(f,s:4:2); end; close(f); readln; end.
нег
нг
ui
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
type group = record gr:string; name:string; bal:byte; end;
var f1,f2:text; i,j:integer; arr: array[0..20] of group;
begin
assign(f1,'file1.txt');
reset(f1);
assign(f2,'file2.txt');
rewrite(f2);
i:=0; while not EOF(f1) do begin read(f1, arr[i].gr); read(f1, arr[i].name); read(f1, arr[i].bal);
i:=i+1; end;
for j:=0 to 20 do begin if arr[j].bal=2 then begin write(f2, arr[j].gr); write(f2, arr[j].name); writeln(f2, arr[j].bal); end;
end;
close(f1);
close(f2);
end.