uses
System.SysUtils,windows,Ab_abonents,Ab_list,Ab_company;
type
Tabonent=record
name,street,flat,house,balance:string;
number:array[1..100] of string;
count:integer;
end;
var Number:array[1..20] of string[20];
Names:array[1..20] of string[20];
Street:array[1..20] of string[20];
House:array[1..20] of string[20];
Flat:array[1..20] of string[20];
Balance:array[1..20] of string[20];
ab:array[1..100] of Tabonent;
function Test(n:integer):string;
var
str: array of string[20];
str2: array of string[20];
str3: array of string[20];
str4: array of string[20];
str5: array of string[20];
str6: array of string[20];
s: string[20];
s1,s2,s3,s4,s5:string[20];
i, j: byte;
count:byte;
FIO:array of string;
Street1:array of string;
House1:array of string;
Flat1:array of string;
Balance1:array of string;
num:array of string;
num2:array of string;
arrofnum:array[1..100] of string;
countarr:integer;
cc:integer;
indexof:integer;
ss:string;
ab:array[1..100] of Tabonent;
k: Integer;
begin
//n:=n*10;
SetLength(str,n+1);
SetLength(str2,n+1); //устанавливаем размер массива
SetLength(str3,n+1);
SetLength(str4,n+1);
SetLength(str5,n+1);
SetLength(str6,n+1);
SetLength(FIO,n+1);
SetLength(Street1,n+1);
SetLength(House1,n+1);
SetLength(Flat1,n+1);
SetLength(Balance1,n+1);
SetLength(num,n+1);
SetLength(num2,n+1);
count:=1;
cc:=1;
countarr:=1;
indexof:=1;
for i:=1 to N do
begin
str[i]:=names[i]; //подготавливаем для сортировки по алфавиту
str2[i]:=Number[i];
str3[i]:=Street[i];
str4[i]:=House[i];
str5[i]:=Flat[i];
str6[i]:=Balance[i];
end;
for i:=1 to N-1 do //сортировка
for j:=1 to N-i do
if str[j][1] > str[j+1][1] then begin
s := str[j];
s1:=str2[j];
s2:=str3[j];
s3:=str4[j];
s4:=str5[j];
s5:=str6[j];
str[j] := str[j+1];
str2[j]:=str2[j+1];
str3[j]:=str3[j+1];
str4[j]:=str4[j+1];
str5[j]:=str5[j+1];
str6[j]:=str6[j+1];
str[j+1] := s;
str2[j+1]:=s1;
str3[j+1]:=s2;
str4[j+1]:=s3;
str5[j+1]:=s4;
str6[j+1]:=s5;
end;
writeln;
for i:=1 to N do
if str[i]<>'' then //если поле не пустое присваем массив к другому массиву
begin
Fio[count]:=str[i];
Street1[count]:=str3[i];
Num[count]:=str2[i];
House1[count]:=str4[i];
Flat1[count]:=str5[i];
Balance1[count]:=str6[i];
inc(count);
end;
I:=0;
while i<=count-1 do
begin
if (Fio[i]=Fio[i+1])then //если имена совпадают
begin
if (num[i][3]=num[i+1][3]) and (num[i][4]=num[i+1][4]) then //сравниваем код оператора
begin
ab[i].name:=Fio[i];
ab[i].street:=street1[i];
ab[i].House:=house1[i];
ab[i].Flat:=Flat1[i];
ab[i].balance:=Balance1[i];
inc(cc,1);
ab[i].number[cc]:=num[i+1];
inc(cc);
inc(i,1);
end;
end
else
begin
end;
inc(i);
end;
for i := 1 to n do
if ab[i].name<>'' then
begin
indexof:=i;
writeln('ФИО:',ab[i].name,' Улица:',ab[i].street,' Дом:',ab[i].house,' Квартира:',ab[i].flat,' Баланс:',ab[i].balance);
end;
end;
function CountSamenum(F:Tcompany):byte; //получаем инфу из текстового файла
var P:Tlist;
count:integer;
i,j: byte;
n:integer;
s:string[100];
begin
count:=1;
P:=F.list^.next;
while p<>nil do
begin
Number[count]:=(p^.info.number);
Names[count]:=p^.info.FIO;
Street[count]:=p^.info.street;
House[count]:=p^.info.house;
Flat[count]:=p^.info.Flat;
Balance[count]:=p^.info.balance;
p:=p^.next;
inc(count);
end;
n:=count;
test(n);
end;
var F:Tcompany;
Max_Exellences:byte;
begin
ab_company.Create('List.txt',F);
Ab_company.Print(F);
CountSameNum(F);
readln;
end.