-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcostrList (14-06-2017)
55 lines (48 loc) · 994 Bytes
/
costrList (14-06-2017)
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
structure node
var info: integer
var link: pointer
end
var head: pointer
Head:= NULL
A)
function costrList_ric(N): listPointer
var temp: pointer
if N > 1 then
temp:= node
temp.info:= N
temp.link:= head
head:= temp
costrList_ric:= costrList_ric(N-1)
else
temp:= node
temp.info:= N
temp.link:= head
head:= temp
end if
end function
B)
function costrList_it(N): listPointer
var i: integer
var current: Pointer
current:= node
head:= current
for i:=1 to N do
current.info:= i
if i=N then
current.link:= NULL
else
current.link:= node
current:= current.link
end if
end for
end function
//FORMA BRUTTA
function costrList_it(N): listPointer
var i: integer
for i:=N to 1 step -1 do
temp:= node
temp.info:= i
temp.link:= head
head:= temp
end for
end function