-
Notifications
You must be signed in to change notification settings - Fork 1
/
list_interchange_sort.f90
48 lines (36 loc) · 1.3 KB
/
list_interchange_sort.f90
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
SUBROUTINE list_interchange_sort
USE linked_list
USE improved_linked_list
IMPLICIT NONE
TYPE (linked_list_t) :: list, list2
CALL create_head(list, 4)
CALL append_tail(list, 6)
CALL append_tail(list, 5)
CALL append_tail(list, 1)
CALL append_tail(list, 8)
CALL append_tail(list, 2)
PRINT *, 'Test 1:'
PRINT *, '*****************************************************************'
PRINT *, 'Transverse the list built up and print the values before sorting:'
CALL print_list(list)
CALL interchange_sort(list)
PRINT *, 'Transverse the list built up and print the values after sorting:'
CALL print_list(list)
PRINT *, '*****************************************************************'
PRINT *, 'Test 2:'
PRINT *, '*****************************************************************'
CALL create_head(list2, 8)
CALL append_tail(list2, 6)
CALL append_tail(list2, 1)
CALL append_tail(list2, 5)
CALL append_tail(list2, 2)
CALL append_tail(list2, 9)
CALL append_tail(list2, 4)
CALL append_tail(list2, 7)
CALL append_tail(list2, 3)
PRINT *, 'Transverse the list built up and print the values before sorting:'
CALL print_list(list2)
CALL interchange_sort(list2)
PRINT *, 'Transverse the list built up and print the values after sorting:'
CALL print_list(list2)
END SUBROUTINE