Program Lab; uses crt; type char_file = file of char; const first_file:string = '02346.txx'; second_file:string = '02345.txx'; third_file = '03.txx'; fourth_file = '04.txx'; function get_word(var f: char_file): string; const chars = ['A' .. 'Z', '0' .. '9']; var s: string; ch: char; more: boolean; begin get_word := ''; s := ''; more := true; while (not eof(f)) and more do begin read(f, ch); if upcase(ch) in chars then s := s + ch else if s <> '' then more := not more end; get_word := s; end; function write_file(var f: text; s: string): byte; begin write(f, s + ' '); write_file := 1 end; var f_first, f_second: char_file; f_third, f_fourth: text; yes_count, no_count: integer; s_one, s_two: string; exists: boolean; sz_1, sz_2: longint; BEGIN assign(f_first, first_file); reset(f_first); sz_1 := filesize(f_first); assign(f_second, second_file); reset(f_second); sz_2 := filesize(f_second); if sz_1 < sz_2 then begin close(f_first); close(f_second); assign(f_first, second_file); reset(f_first); assign(f_second, first_file); reset(f_second); end; assign(f_third, third_file); rewrite(f_third); assign(f_fourth, fourth_file); rewrite(f_fourth); yes_count := 0; no_count := 0; while not eof(f_first) do begin s_one := get_word(f_first); reset(f_second); exists := false; while (not eof(f_second)) and (not exists) do exists := (s_one = get_word(f_second)); if exists then inc(yes_count, write_file(f_third, s_one)) else inc(no_count, write_file(f_fourth, s_one)) end; reset(f_second); while not eof(f_second) do begin s_one := get_word(f_second); reset(f_first); exists := false; while (not eof(f_first)) and (not exists) do exists := (s_one = get_word(f_first)); if not exists then inc(no_count, write_file(f_fourth, s_one)) end; writeln('yes: ', yes_count); writeln('no: ', no_count); close(f_fourth); close(f_third); close(f_second); close(f_first) END.