计算机等级考试二级C语言链表复习资料

2026/4/28 0:15:39

scanf(\s->llink=p; s->rlink=NULL; p=s; }

h->llink=s; p->rlink=h; return(h); }

stud * search(stud *h,char *x) { stud *p; char *y; p=h->rlink; while(p!=h) {

y=p->name;

if(strcmp(y,x)==0) return(p); else p=p->rlink; }

printf(\没有查找到该数据!\}

void print(stud *h) { int n; stud *p; p=h->rlink;

printf(\数据信息为:\\n\while(p!=h) {

printf(\p=p->rlink; }

printf(\}

void del(stud *p) {

(p->rlink)->llink=p->llink; (p->llink)->rlink=p->rlink; free (p); } main() {

int number; char studname[20]; stud *head,*searchpoint; number=N; clrscr();

head=creat(number); print(head);

printf(\请输入你要查找的人的姓名:\scanf(\

searchpoint=search(head,studname);

printf(\你所要查找的人的姓名是:%s\\n\del(searchpoint); print(head); }

在这里列举了一个应用单链表基本算法的综合程序,双向链表和循环链表的综合程序大家可以自己去试一试。 #include #include #include #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(\不能分配内存空间!\exit(0); }

h->name[0]='\\0'; h->link=NULL; p=h;

for(i=0;i

if((s= (stud *) malloc(sizeof(stud)))==NULL) {

printf(\不能分配内存空间!\exit(0); }

p->link=s;

printf(\请输入第%d个人的姓名\scanf(\s->link=NULL; p=s; }

return(h); }

stud * search(stud *h,char *x) { stud *p; char *y; p=h->link; while(p!=NULL) {

y=p->name;

if(strcmp(y,x)==0) return(p); else p=p->link; }

if(p==NULL)

printf(\没有查找到该数据!\}

stud * search2(stud *h,char *x) {

stud *p,*s; char *y; p=h->link; s=h;

while(p!=NULL) {

y=p->name;

if(strcmp(y,x)==0) return(s); else {

p=p->link; s=s->link; } }

if(p==NULL)

printf(\没有查找到该数据!\}

void insert(stud *p) {

char stuname[20]; stud *s;

if((s= (stud *) malloc(sizeof(stud)))==NULL) {

printf(\不能分配内存空间!\exit(0); }

printf(\请输入你要插入的人的姓名:\scanf(\strcpy(s->name,stuname); s->link=p->link; p->link=s; }

void del(stud *x,stud *y) { stud *s; s=y;

x->link=y->link;


计算机等级考试二级C语言链表复习资料.doc 将本文的Word文档下载到电脑
搜索更多关于: 计算机等级考试二级C语言链表复习资料 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219