Мой сайт

Первый блин

2026-11-11

Trace into — пошаговая «отладка» этой программы

var { --- Global --- }
    infile, outfile : text;
    counter: Integer;

procedure handle_string;
var { -- handle_string -- }
    n, cnt, sum, Rating : Integer;
begin
    sum := 0;
    cnt := 0;
    while not Eoln(infile) do begin
        read(infile, n);
        sum := sum + n;
        cnt := cnt + 1;
    end;
    if cnt > 0 then begin
        Rating := sum div cnt;  // rat крыса -ing
        WriteLn(outfile, counter, cnt, sum, Rating);        
    end
    else
        WriteLn(outfile, counter, '  Ученик не аттестован'); 
end; // handle_string    


begin { - main - }
    counter := 0;
    Assign(infile, 'p_30_1.in'); // не AssignFile, просто Assign
    Reset(infile);
    Assign(outfile, 'p_30_1.out'); // в fp  н е т  такого "AssignFile"
    Rewrite(outfile);
    WriteLn(outfile, 'Номер    Количество    Сумма     Средний');
    WriteLn(outfile, 'ученика  оценок        баллов    балл');
    while not Eof(infile) do begin
      counter := counter + 1;
      handle_string;
    end;
    Close(infile);
    Close(outfile);
end.