summaryrefslogtreecommitdiff
path: root/src/01/02b/doubly_linked_list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/01/02b/doubly_linked_list.c')
-rw-r--r--src/01/02b/doubly_linked_list.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/01/02b/doubly_linked_list.c b/src/01/02b/doubly_linked_list.c
index 88e49ee..4bb71b8 100644
--- a/src/01/02b/doubly_linked_list.c
+++ b/src/01/02b/doubly_linked_list.c
@@ -92,21 +92,22 @@ Node *reverse(Node *head) {
static void print(Node *node) {
if (node->prev && node->next)
- printf("%d <- %d -> %d\n", node->prev->data, node->data, node->next->data);
+ printf("(%d<%d>%d)", node->prev->data, node->data, node->next->data);
else if (node->next)
- printf("nil <- %d -> %d\n", node->data, node->next->data);
+ printf("(nil<%d>%d)", node->data, node->next->data);
else
- printf("%d <- %d -> nil\n", node->prev->data, node->data);
+ printf("(%d<%d>nil)", node->prev->data, node->data);
}
-static void inspect(Node *node) {
+void inspect(Node *node) {
if (!node) return;
- printf("*******\n");
+ printf("[ ");
while (node) {
print(node);
+ printf(" ");
node = node->next;
}
- printf("*******\n");
+ printf("]\n");
}