0

Help me to use nested LinkedList for expressing Matrix. Thanks.

Where is error in my code?

```
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct Node {
int Data;
struct Node *Next;
};
struct LinkedList {
Node *Head; Node *Tail;
struct LinkedList *Next1;
};
struct LinkedList1 {
LinkedList *Head1; LinkedList *Tail1;
int n;
};
void insertTail (LinkedList &List, int x) {
Node *p; p = new Node;
p->Data = x; p -> Next = NULL;
if (List.Head == NULL) {
List.Head = p; List.Tail = List.Head; }
else {
List.Tail->Next = p; List.Tail = p; }
}
void insertTail (LinkedList1 &a, LinkedList &b) {
LinkedList *p; p = new LinkedList;
p->Head = b.Head; p -> Next1 = NULL;
if (a.Head1 == NULL) {
a.Head1 = p; a.Tail1 = a.Head1; }
else {
a.Tail1->Next1 = p; a.Tail1 = p; }
}
void Output (LinkedList1 & List) {
LinkedList *q; q = List.Head1;
Node *p; p = q->Head; int a, n = List.n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (j == 0) printf ("\n");
printf ("%d ", p->Data);
p = p->Next; }
q = q->Next1; p = q->Head;
} }
void createList (LinkedList1 &List, int *x, int n) {
int k = 0; List.Head1 = NULL; List.n = n;
LinkedList *a; a = new LinkedList [n];
for (int i = 0; i < n; i++) {
a[i].Head = NULL; insertTail (List, a[i]);
for (int j = 0; j < n; j++) {
insertTail (a[i], x[k]); k++; }
} }
int getData (LinkedList1 &List, int i, int j) {
LinkedList *q; q = List.Head1; int b;
Node *p; p = q->Head;
for (int i1 = 0; i1 < i; i1++) {
for (int j1 = 0; j1 < j; j1++) {
b = p->Data; p = p->Next; }
q = q->Next1; p = q->Head; }
return b;
}
void main() {
int x1[9] = { 3, 7, 9, 11, 17, 13, 15, 23, 26 };
int x2[9] = { 6, 8, 15, 14, 19, 23, 25, 27, 21 };
LinkedList1 a; createList (a, x1, 3);
Output (a); printf ("\n");
system (“pause”);
}
```