/* --- DO NOT SUBMIT main() !!! --- */
/* --- submit EVERYTHING ELSE except main() --- */
/* --- containing the #include directives and struct definition --- */
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
typedef struct node node_t;
typedef struct linked_list {
node_t *head;
node_t *tail;
} linked_list_t;
void initialize(linked_list_t*) {
/*
* You can use Lec 9-1's code here
*/
}
void free_list(linked_list_t*) {
/*
* You can use Lec 9-1's code here
*/
}
void output_list(linked_list_t*) {
/*
* You can use Lec 9-1's code here
*/
}
void add_node(linked_list_t*, int) {
/*
* You can use Lec 9-1's code here
*/
}
void reverse_list(linked_list_t*) {
/*
* Your code here !
*/
}
int main() {
linked_list_t my_list;
initialize(&my_list);
node_t *middle_ptr;
int data, input_size;
/* when you add a node, you add it at the tail */
scanf("%d\n", &input_size);
for(int i=0; i < input_size; ++i) {
scanf("%d", &data);
add_node(&my_list, data);
}
reverse_list(&my_list);
output_list(&my_list);
free_list(&my_list);
return 0;
}
8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1