0 / 0 / 0
Регистрация: 09.04.2015
Сообщений: 51
|
|
1
|
Записи упорядочены
13.12.2015, 22:49. Показов 475. Ответов 0
Написал 1-ую часть лабы, со второй частью испытываю небольшие траблы.
Собственно, 2-я часть:
Записи упорядочены по общей площади и улице. Напечатать улицы и номера домов, в которых расположены самые крупногабаритные квартиры.
Мои наработки:
Delphi | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| program kvartira;
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows,
Un_Biz in 'C:\Users\insins\Desktop\Lab1\Un_Biz.pas',
Un_List_Biz in 'C:\Users\insins\Desktop\Lab1\Un_List_Biz.pas',
Un_Account in 'C:\Users\insins\Desktop\Lab1\Un_Account.pas';
Var P:TAccount; user_client:string;
Begin
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
Un_Account.Create('C:\Users\insins\Desktop\Lab1\1.txt',P);
Un_Account.Print(P);
Readln;
end. |
|
Delphi | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| unit Un_Account;
interface
uses
Un_List_Biz;
type
TAccount=record
name:string;
list:TList
end;
procedure Create(file_name:string; var P:TAccount);
procedure Print(P:TAccount);
procedure Clear (var P:TAccount);
implementation
procedure Create(file_name:string; var P:TAccount);
var t:TextFile;
begin
assignfile(t,file_name);
Reset(t);
Readln(t,P.name);
Un_List_Biz.Create(t,P.list);
CloseFile(t)
end;
procedure Print(P:TAccount);
begin
Writeln(P.name);
Writeln('--------------------------');
Un_List_Biz.Print(P.list);
end;
procedure Clear (var P:TAccount);
begin
Un_List_Biz.Clear(P.list)
end;
end. |
|
Delphi | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
| unit Un_Biz;
interface
type
TBiz=record
kkomnat:1..10;
etaj:1..55;
ploshad:record
obsh :1..250;
jil: 1..200;
end;
kjilc: 1..10;
adres:record
street:string;
nomerkv: 1..200;
nomerdoma:1..200;
end;
end;
procedure ReadBiz(var B:TBiz);overload;
procedure ReadBiz(var t:TextFile; var B:TBiz);overload;
procedure WriteBiz(B:TBiz);
function Compare(B1,B2:TBiz):integer;
implementation
procedure ReadBiz(var B:TBiz);
begin
write('Êîëè÷åñòâî êîìíàò: ');
Readln(B.kkomnat);
write('Ýòàæ: ');
Readln(B.etaj);
Write('Ïëîùàäü îáùàÿ: ');
Readln(B.ploshad.obsh);
Write('Ïëîùàäü æèëàÿ: ');
Readln(B.ploshad.jil);
Write('Êîëè÷åñòâî æèëüöîâ: ');
Readln(B.kjilc);
Write('Àäðåñ(Óëèöà,N êâàðòèðû, N äîìà: ');
Readln(B.adres.street,B.adres.nomerkv,B.adres.nomerdoma);
Readln
end;
procedure ReadBiz(var t:TextFile; var B:TBiz);
begin
Readln(t,B.kkomnat);
Readln(t,B.etaj);
Readln(t,B.ploshad.obsh);
Readln(t,B.ploshad.jil);
Readln(t,B.kjilc);
Readln(t,B.adres.street);
Readln(t,B.adres.nomerkv);
Readln(t,B.adres.nomerdoma);
if not Eof(t) then Readln(t)
end;
procedure WriteBiz(B:TBiz);
begin
writeln('Êîëè÷åñòâî êîìíàò: ',B.kkomnat);
writeln('Ýòàæ:', B.etaj);
writeln('Ïëîùàäü');
Writeln('Îáùàÿ : ',B.ploshad.obsh);
Writeln('Æèëàÿ: ', B.ploshad.jil);
Writeln('Êîë-âî æèëüöîâ: ', B.kjilc);
writeln('Àäðåñ: ');
writeln('Óëèöà: ',B.adres.street);
writeln('Íîìåð êâàðòèðû: ',B.adres.nomerkv);
writeln('Íîìåð äîìà: ',B.adres.nomerdoma);
writeln;
writeln('--------------------------');
end;
function Compare(B1,B2:TBiz):integer;
begin
if (B1.ploshad.obsh<B2.ploshad.obsh)
then result:=-1
else
if (B1.ploshad.obsh=B2.ploshad.obsh)
then result:=0
else result:=1
end;
end. |
|
Delphi | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
| unit Un_List_Biz;
interface
uses
Un_Biz;
type
TList=^TNode;
TNode=record
info:TBiz;
next:TList;
end;
procedure Create(var f:TextFile; var L:TList);
procedure Print(L:TList);
procedure Clear(var L:TList);
function Del_after_Q(var Q:TList):TBiz;
implementation
procedure Init(var L:TList);
begin
New(L);
L^.next:=nil
end;
function Empty(L:TList):Boolean;
begin
result:=L^.next=nil
end;
procedure Add_after_Q(var Q:TList; new_biz:TBiz);
var p:TList;
begin
new(p);
p^.info:=new_biz;
p^.next:=Q^.next;
Q^.next:=p
end;
function Del_after_Q(var Q:TList):TBiz;
var p:TList;
begin
p:=Q^.next;
Q^.next:=p^.next;
result:=p^.info;
Dispose(p)
end;
function Found_place(L:TList;new_biz:TBiz):TList;
begin
result:=L;
while (result^.next<>nil) and (Un_Biz.Compare(result^.next^.info,new_biz)<0)
do result:=result^.next
end;
procedure Create(var f:TextFile; var L:TList);
var new_biz:TBiz; Q:TList;
begin
Init(L);
while not Eof(f) do
begin
ReadBiz(f,new_biz);
Q:=Found_place(L,new_biz);
Add_after_Q(Q,new_biz);
end;
end;
procedure Print(L:TList);
var p:TList;
begin
p:=L^.next;
while p<>nil do
begin
WriteBiz(p^.info);
p:=p^.next
end;
end;
procedure Clear(var L:TList);
begin
while not Empty(L)
do Del_after_Q(L);
Dispose(L)
end;
end. |
|
0
|