#include<stdio.h>
#include<malloc.h>
typedef struct Node
{
int data;
struct Node *next;
}Node, *CreateList;
void InsertList(CreateList *L, int m)
{
Node *t, *s;
s = *L;
while (m > s->next->data && s->next->next != NULL) s = s->next;
if (s->next->next == NULL)
{
t = (Node*)malloc(sizeof(Node));
t->data = m;
s->next->next = t;
s = t;
s->next = NULL;
}
else
{
t = (Node*)malloc(sizeof(Node));
t->data = m;
t->next = s->next;
s->next = t;
}
}
void Print(CreateList L)
{
Node *p;
p = L->next;
while (p->next)
{
printf("%d ", p->data);
p = p->next;
}printf("%d", p->data);
}
int main()
{
CreateList L;
int i, a, m, n;
Node *last, *p;
L = (CreateList)malloc(sizeof(Node));
L->data = 0;
L->next = NULL;
last = L;
scanf("%d %d", &n, &m);
for (i = 0; i < n; i++)
{
scanf("%d", &a);
p = (Node*)malloc(sizeof(Node));
p->data = a;
p->next = NULL;
last->next = p;
last = p;
}
InsertList(&L, m);
Print(L);
return 0;
}
p = (Node*)malloc(sizeof(Node));和 L = (CreateList)malloc(sizeof(Node));这个有什么区别?
刚刚学习数据结构,请问各位大佬这两个的区别在哪里