You have to write a function called linked_list_to_matrix which returns a matrix of size
n*m (n rows, m columns) containing the values of the linked list lst. For example,
with the linked list containing the following values : first -> 1-2-3-4-5-6-7-8-9
pour n=3, m=3 renvoie : [[1 2 3] [4 5 6] [7 8 9]] pour n=2, m=3 renvoie : [[1 2 3] [4 5 6]] pour n=3, m=4 renvoie : [[1 2 3 4] [5 6 7 8] [9 -1 -1 -1]]
Note that if there isn't enough values in the linked list to fill the matrix, the remaining empty cells should contain -1
.
Here's the definition of the linked list :
typedef struct node{ struct node* next; int value; } node_t; typedef struct list{ struct node* first; int size; } list_t;