一个指针数组,每个数组里的元素是指向一些链表的头结点
编写一个C++程序:定义一个指针数组,然后数组里面存放的是动态创建的一些链表的头结点地址,我编写的编译通不过,求各位大神帮帮忙,求指导。。程序代码:
#include <stdio.h> #include <malloc.h> #include <stdlib.h> const int n = 5; typedef struct LinkLNdoe { int no; int Data; struct LinkLNode *next; }LinkLNode,*LinkList; LinkLNode *head,*end; LinkLNode *Array_FirstLinkListCreat( LinkList &L,int m ) { int i = 0,j = 0; LinkLNode *Array[n+1]; LinkLNode *p = NULL,*q = NULL; for( i = 1;i <= n;i++ ) { p = q = l = (LinkLNode *)malloc(sizeof(LinkLNode)); Array[i] = p; p->no = 1; head = end = p; } for( i = 1;i <= n;i++ ) { for( j = 2;j <= m ;j++ ) { q = l = (LinkLNode *)malloc(sizeof(LinkLNode)); q->no = j; end->next = q; end = p = q; end->next = NULL; } } return (Array[1]); } int main () { LinkList L; LinkLNode *p,*q; int m = 3; int i = 0,j = 0; p = Array_FirstLinkListCreat( L,m ); system("pause"); return 0; }