diff options
| author | mo khan <mo.khan@gmail.com> | 2020-07-05 14:01:59 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-07-05 14:01:59 -0600 |
| commit | 8bf32957fef23b85b1421c38b6416047bcba476e (patch) | |
| tree | 3eece4d270f52c91a6c22e84b6eb636fd57326c1 /src/01/05 | |
| parent | e27441426cd127c1f9969da1fcd2fde0ab415586 (diff) | |
run make fmt
Diffstat (limited to 'src/01/05')
| -rw-r--r-- | src/01/05/doubly_linked_list.c | 14 | ||||
| -rw-r--r-- | src/01/05/doubly_linked_list_test.c | 6 | ||||
| -rw-r--r-- | src/01/05/main.c | 7 |
3 files changed, 13 insertions, 14 deletions
diff --git a/src/01/05/doubly_linked_list.c b/src/01/05/doubly_linked_list.c index 509c698..006b194 100644 --- a/src/01/05/doubly_linked_list.c +++ b/src/01/05/doubly_linked_list.c @@ -14,7 +14,7 @@ Node *add(Node *head, int data) { Node *tail; Node *tmp = head; - while(tmp) { + while (tmp) { if (!tmp->next) break; tmp = tmp->next; @@ -26,9 +26,10 @@ Node *add(Node *head, int data) { } Node *get(Node *from, int index) { - if (!from || index < 0) return NULL; + if (!from || index < 0) + return NULL; - while(index > 0 && from){ + while (index > 0 && from) { from = from->next; index--; } @@ -37,7 +38,8 @@ Node *get(Node *from, int index) { static int size(Node *head) { int i = 0; - for (Node *tmp = head; tmp && tmp != NULL; tmp = tmp->next) i++; + for (Node *tmp = head; tmp && tmp != NULL; tmp = tmp->next) + i++; return i; } @@ -80,7 +82,8 @@ static void print(Node *node) { } void inspect(Node *node) { - if (!node) return; + if (!node) + return; printf("[ "); while (node) { @@ -90,4 +93,3 @@ void inspect(Node *node) { } printf("]\n"); } - diff --git a/src/01/05/doubly_linked_list_test.c b/src/01/05/doubly_linked_list_test.c index e674917..8bf9265 100644 --- a/src/01/05/doubly_linked_list_test.c +++ b/src/01/05/doubly_linked_list_test.c @@ -1,9 +1,9 @@ -#include <cgreen/cgreen.h> #include "doubly_linked_list.h" +#include <cgreen/cgreen.h> Describe(DoublyLinkedList); -BeforeEach(DoublyLinkedList){ } -AfterEach(DoublyLinkedList){ } +BeforeEach(DoublyLinkedList) {} +AfterEach(DoublyLinkedList) {} Ensure(DoublyLinkedList, when_reversing_a_short_list) { Node *head = initialize(100); diff --git a/src/01/05/main.c b/src/01/05/main.c index ec56b42..1bb3f9d 100644 --- a/src/01/05/main.c +++ b/src/01/05/main.c @@ -2,12 +2,9 @@ #include <stdio.h> #include <stdlib.h> -int next(void) { - return rand() % 100; -} +int next(void) { return rand() % 100; } -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { printf("=== COMP-272 - Assignment 1 - Question 5 ===\n"); Node *head = initialize(0); |
