大神急救,急救啊,真的急救啊,程序怎么错,真的看不出。
#include<stdio.h>
#include<stdlib.h>
#define m 3
#define n 4
#define p 5
typedef struct Student
{
float score;
struct Student *next;
}Student;
Student *CreateAndInit(int Nodes,float Lscore[]);
/*
** main function
*/
int main(void)
{
float LAscore[m] = {1,3,4};
float LBscore[n] = {3,4,5,6};
float LCscore[p] = {1,3,4,6,7};
Student *LA = NULL, *LB = NULL, *LC = NULL;
//Create and initialize the link
LA = CreateAndInit(m,LAscore);
LB = CreateAndInit(n,LBscore);
LC = CreateAndInit(p,LCscore);
return 0;
}
//Create and initialize the link
Student *CreateAndInit(int Nodes,float Lscore[])
{
int i;
Student *head = NULL, *p = NULL, *p1 = NULL;
head = p = p1 = (Student *)malloc(sizeof(Student));
head -> next = NULL;
head ->score = Lscore[0];
for(i = 0; i < Nodes - 1; ++i)
{
p = (Student *)malloc(sizeof(Student));
p -> next = NULL;
p -> score = Lscore[i + 1];
p1 ->next = p;
p1 = p;
}
return head;
}
Student *head = ((void *)0), *5 = ((void *)0), *p1 = ((void *)0);
#define p 5