#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef struct info
{
int no;
char name[20];
int depno;
int salary;
}StaffBill;
typedef struct LNode
{
StaffBill data;
struct LNode * next;
}LinkList;
void CreateList(LinkList * &L, StaffBill a [], int n); //函数原型
void DispList(LinkList * L);
void CreateList(LinkList * &L, StaffBill a [], int n) //尾插法建链表L
{
LinkList * s, *r;
int i;
L = (LinkList *) malloc(sizeof(LinkList));
r = L;
for (i = 0; i < n; i++)
{
s = (LinkList *) malloc(sizeof(LinkList));
s->data = a[i];
r->next = s;
}
r->next = NULL;
}
void DispList(LinkList * L) //输出链表L
{
LinkList * p = L->next;
while (p != NULL)
{
printf("%d %s %d %d", p->data.no, p->data.name, p->data.depno, p->data.salary);
p = p->next;
}
printf("/n");
}
void main()
{
struct StaffBill Info[3] = { {33541, "德维恩.韦德", 003, 115500}, //这里有错误提示:1 IntelliSense: 不允许使用不完整的类型 (具体在Info处)
{ 33677, "勒布朗.詹姆斯", 006, 150000 },
{ 33431, "科比.布莱恩特", 024, 100000 } };
LinkList * L;
CreateList(L, Info[3], 3); //这里错误提示2 IntelliSense: 表达式必须是指向完整对象类型的指针 (info处)
DispList(L);
}
慕虎7371278