Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program project1;
- uses
- SysUtils, Windows
- { you can add units after this };
- const
- filename = 'input.txt';
- N = 10;
- region_max = 99;
- type
- address = record
- street: string[20];
- home_num: integer;
- flat_num: integer;
- end;
- edition = record
- title: string[20];
- is_magazine: boolean;
- monthes: array [1..12] of boolean;
- end;
- subscriber = record
- fio: string[20];
- target: 1..region_max; {участок доставки}
- the_address: address;
- count: integer;
- editions: array [1..N] of edition;
- end;
- AllRegions = array [1..region_max] of integer;
- function readStruct(var f: textFile): subscriber;
- var
- s: String;
- //res: subscriber;
- cnt, b, e: integer;
- i, j: integer;
- begin
- readln(f, result.fio);
- readln(f, s);
- result.target:=strToInt(s);
- readln(f, s); {Count of editions subscribe}
- cnt := strToInt(s);
- result.count := cnt;
- {address block}
- readln(f, result.the_address.street);
- readln(f, s);
- result.the_address.home_num :=strToInt(s);
- readln(f, s);
- result.the_address.flat_num :=strToInt(s);
- {edition block}
- for i := 1 to cnt do begin
- readln(f, result.editions[i].title);
- readln(f, s);
- result.editions[i].is_magazine := s = 't';
- readln(f, s);
- b := StrToInt(copy(s, 1, pos('-', s)-1));
- e := StrToInt(copy(s, pos('-',s) + 1, length(s)));
- for j := b to e do begin
- result.editions[i].monthes[j] := true;
- end
- end;
- end;
- var
- f : TextFile;
- person: subscriber;
- s: String;
- prevFIO : string;
- Cnt : integer;
- resFIO : string;
- resCnt : integer;
- begin
- SetconsoleCP(1251);
- SetconsoleOutputCP(1251);
- AssignFile(f, filename);
- // Open the file for reading
- reset(f);
- resFIO := '';
- resCnt := 0;
- prevFIO:= '';
- Cnt := 0;
- while not eof(f) do
- begin
- person := readStruct(f);
- writeln('Person: ', person.fio, ' cnt: ', person.count);
- if not eof(f) then
- readln(f, s);
- if person.FIO = prevFIO
- then Cnt := Cnt + person.count
- else Cnt := person.count;
- prevFIO := person.FIO;
- if Cnt > resCnt then begin
- resCnt := Cnt;
- resFIO := prevFIO;
- end;
- writeln('***'+#13+#10);
- end;
- CloseFile(f);
- Writeln(ResFIO) ;
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement