master
1#include "doubly_linked_list.h"
2#include <stdio.h>
3#include <stdlib.h>
4
5int next(void) { return rand() % 100; }
6
7int main(int argc, char *argv[]) {
8 printf("=== COMP-272 - Assignment 1 - Question 2b ===\n");
9 Node *head = initialize(next());
10 Node *new_head = NULL;
11
12 for (int i = 0; i < 9; ++i)
13 add(head, next());
14
15 printf("\t");
16 inspect(head);
17
18 new_head = get(head, 1);
19 swap(head, new_head);
20 head = new_head;
21 printf("swap: 0,1\n\t");
22 inspect(head);
23
24 for (int i = 2; i < 10; i += 2) {
25 swap(get(head, i), get(head, i + 1));
26 printf("swap: %d,%d\n\t", i, i + 1);
27 inspect(head);
28 }
29
30 return 0;
31}