21

Re: Записи. Допоможіть з умовою [Вирішено]

Program lab13;
type book = record
  surname:string[20];
  zp:integer;
  pd:integer;
  max:real;
end;
  
var b:text;
      gr:array [1..5] of book; i,j:integer;
      a:string; AllTax,MaxTax, CurrentUserNumber,s:integer;
begin
  a:='c:\tp7\lab13.txt';
  for i:=1 to 5 do
  begin
    writeln ('vvedu prizvushe '); readln(gr[i].surname);
    writeln (' zarplata '); readln(gr[i].zp);
    writeln (' podatok '); readln(gr[i].pd);
  end;
  
  begin
    assign(b,a);
    rewrite(b);
    for i:=1 to 5 do
      writeln(b,gr[i].surname:20,gr[i].zp:14,gr[i].pd:7);
    close(b);
  end;
  
  reset(b);
  s:=0; alltax:=0;maxtax:=0;
  for i:=1 to 5 do
  begin 
    alltax:=alltax+gr[i].pd;
    s:=s+gr[i].zp;
  end;
          
  for i:=1 to 5 do
  begin
    if maxtax<gr[i].pd then
    begin
      maxtax:=gr[i].pd;
      CurrentUserNumber:=i;
    end;  
  end;
         
  Write (gr[CurrentUserNumber].surname,',',s);
end.
Подякували: Chemist-i1