小白求教,单链表怎么调用啊啊啊
#include <stdio.h>#include<stdlib.h>
typedef struct student
{
int score;
struct student *next;
}Link;
Link *creat(int);
void change(Link *head,int n);
void delet(Link *head,int n);
void insert(Link *head,int n);
void print(Link *head,int n);
Link *creat(int n)
{
Link *head,*node,*end;
head=(Link*)malloc(sizeof(Link));
end=head;
int i;
for (i=0;i<n;i++)
{
node=(Link*)malloc(sizeof(Link));
scanf("%d",&node->score);
end->next=node;
end=node;
}
end->next=NULL;
return head;
}
void change(Link *head,int n)
{
Link *t=head;int i=0;
while(i<n&&t!=NULL)
{t=t->next;
i++;
}
if(t!=NULL) scanf("%d",&t->score);
else printf("none");
}
void delet(Link *head,int n)
{
Link *t=head,*i;int j=0;
while(j<n&&t!=NULL)
{i=t;
t=t->next;
j++;
}
if(t!=NULL)
{i->next=t->next;
free(t);
}
else printf("none");
}
void insert(Link *head,int n)
{
Link *t=head,*i;int j=0;
i=(Link *)malloc(sizeof(Link));
scanf("%d",&i->score);
while(j<n&&t!=NULL)
{t=t->next;
j++;
}
if(t!=NULL)
{i->next=t->next;
t->next=i;
}
else printf("none");
}
void print(Link *head,int n)
{
int i=0;
while(i<n)
{head=head->next;
printf("%d",head->score);
i++;
}
}
main()
{
Link *p;
p=Link *creat(5);
print(p,5);
}