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;
};
};
int n;
};

void  insertTail  (LinkedList &List, int x)  {
Node *p;  p = new Node;
p->Data = x;  p -> Next = NULL;
else  {
List.Tail->Next = p;  List.Tail = p; }
}
else  {
a.Tail1->Next1 = p;  a.Tail1 = p; }
}
void  Output  (LinkedList1 & List)  {
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;
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)  {
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”);
}``````

Edited by chuong3a: n/a

2
Contributors
1
2
Views
8 Years
Discussion Span
Last Post by Lerner

First, decide if you are doing this in C or C++. Your headers and output statement indicate C, but your memory allocation using the keyword new is C++.

If this is supposed to be in C, then you would be best advised to post it on the C board.

The return type of main() should be int, not void. Even if your current compiler allows you to use type void, don't do it.

I'd also recommend compiling after writing no more than than few lines, or at most a small funciton, and not try debugging the whole program at once.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.