-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc.cpp
More file actions
69 lines (55 loc) · 1.27 KB
/
func.cpp
File metadata and controls
69 lines (55 loc) · 1.27 KB
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
#include "head.h"
void createList(List &L){
/*membuat sebuah list baru*/
first(L) = nil;
};
adr newElement(infotype x){
/*membuat element baru dengan input isi element*/
adr P;
P = new element;
info(P) = x;
next(P) = nil;
return(P);
};
void insertLast(List &L, adr P){
/*memasukan element ke belakang list*/
adr Q = first(L);
if(Q != nil){
while(next(Q) != nil) {
Q = next(Q);
}
next(Q) = P;
next(P) = nil;
} else {
first(L) = P;
}
};
void printList(List L){
/*menuliskan semua data yang tersimpan*/
adr P;
int i;
if(first(L) == nil){
cout << "List kosong!" << endl;
} else {
i = 1;
P = first(L);
while(P != nil){
cout<< i <<". Nama :" << info(P) <<endl;
P = next(P);
i++;
};
cout<< "List selesai ditampilkan!" <<endl;
}
};
void show5Org(List L){
/*Procedure show data 5 orang pertama yang datang ke
perpustakaan. List bisa saja kosong atau berisi kurang dari 5 orang*/
int i = 1;
adr P = first(L);
cout << "Lima orang pertama :" <<endl;
while(i<=5 && P != nil){
cout<< i <<". Nama :" << info(P) <<endl;
P = next(P);
i++;
}
};