2 { use string array and use procedure }
3 { tips for fpc - "fpc -mTP name_prog.pas" }
5 IN_FILE_PATH = 'task_15.in';
6 OUT_FILE_PATH = 'task_15_mod_2.out';
12 END_PHONE = MAX_LENGTH_LINE;
14 result_line_type = string[MAX_LENGTH_LINE];
15 in_lines_type = array [1..MAX_LINES] of string[MAX_LENGTH_LINE];
17 in_file, out_file: text;
19 in_lines: in_lines_type;
20 result_line: result_line_type;
22 procedure find_min_phone_and_first_letter_family( i: integer; var result_line: result_line_type );
28 if in_lines[i,START_FAMILY] <= result_line[START_FAMILY] then
30 for t:=START_PHONE to END_PHONE do
32 if in_lines[i,t] <> result_line[t] then
34 if in_lines[i,t] < result_line[t] then
36 result_line := in_lines[i];
44 result_line := in_lines[i];
46 {END procedure find_min_phone_and_first_letter_family}
48 assign( in_file, IN_FILE_PATH);
50 assign( out_file, OUT_FILE_PATH);
53 for i:=1 to MAX_LINES do
55 {START read from in_file and write in out_file}
56 readln( in_file, in_lines[i]);
57 writeln( out_file, in_lines[i]);
59 find_min_phone_and_first_letter_family( i, result_line );
64 writeln(out_file,'Result');
65 writeln(out_file,result_line);