#include<stdio.h>#include<malloc.h>struct stu
{
char name[20];int score;struct stu *next;};struct stu *createlink(int n)//建立一个具有n个结点的链表,最后返回该链表的头结点,该函数为结构体指针型函数{
struct stu *head,*p,*q;int i;if(n<=0)return(NULL);
head=(struct stu *)malloc(sizeof(struct stu));//创建第一个结点,然后把它的地址赋值头结点printf("input name and score:");scanf("%s%d",head->name,&head->score);//给第一个结点输入数据,不要问我为什么第一个head前不加&,你冷静点,人家可是数组耶
p=head;//把头结点赋给p,使p指向第一个结点for(i=1;i<n;i++)//创建剩下的结点{
q=(struct stu *)malloc(sizeof(struct stu));printf("input name and score:");scanf("%s%d",q->name,&q->score);//输入数据
p->next=q;//把q结点的地址赋给上一个结点的指针域
p=q;//p跳到q上来,依次连接后面的各个结点}
p->next=
@献给刚学C语言链表的同学们,这个程序包含链表所有的功能,包括创建链表、增加结点、删除结点、修改结点、遍历链表的功能,内容简单,注释全面!#include <stdio.h>#include <malloc.h>struct stu{ char name[20]; int score; struct stu *next;};struct stu *createlink(int n) //建立一个具有n个结点的链表,最后返回该链表的头结点,该函数为