在這里列舉了一個(gè)應(yīng)用單鏈表基本算法的綜合程序,雙向鏈表和循環(huán)鏈表的綜合程序大家可以自己去試一試。
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#define N 10
typedef struct node
{
char name[20];
struct node *link;
}stud;
stud * creat(int n)
{
stud *p,*h,*s;
int i;
if((h=(stud *)malloc(sizeof(stud)))==NULL)
{
printf(“不能分配內(nèi)存空間!”);
exit(0);
}
h->name[0]=’