算法与数据结构实验

loading 分享 2026-8-20 下载文档

.

p=(Node*)malloc(sizeof(Node)); p->data=x; r->next=p; r=p;

}

r->next=NULL; return head; }

void output(Linklist head) { }

void main()

printf(\ do{

printf(\ p=p->next; p=head->next; Linklist p;

}while(p);

.

.

{ } (2)

#include #include typedef struct node {

int data;

struct node *next; } linklist; main() { int x,y;

Linklist head; int x,n;

printf(\输入数字的个数(n):\\n\ scanf(\ head=creat(n); printf(\输出数字:\\n\ output(head);

.

.

linklist *h,*s,*r,*p,*q,*m,*n; h=malloc(sizeof(linklist)); r=h;

printf(\请输入一个数组 :\ scanf(\ while(x!=0) {

s=malloc(sizeof(linklist)); s->data=x; r->next=s; r=s;

scanf(\ }

r->next=NULL; printf(\请输入插入值:\ scanf(\ p=h->next; while(p!=NULL) {

if ((p->data)

p=p->next;

else

.

.

}

break;

q=malloc(sizeof(linklist)); q->data=y; m=h;

while(m->next!=p)

m=m->next;

q->next=p; m->next=q; n=h->next;

printf(\这个链表是:\ while(n!=NULL) {

printf(\ n=n->next; } } (3)

#include #include typedef struct node {

.

.

int data;

struct node *next; } linklist; main() { int x;

linklist *h,*s,*r,*p,*q,*t; h=malloc(sizeof(linklist)); r=h;

printf(\请输入一个数组:\ scanf(\ while(x!=-1) {

s=malloc(sizeof(linklist)); s->data=x; r->next=s; r=s;

scanf(\ }

r->next=NULL;

printf(\这个链表是:\\n\

.


算法与数据结构实验.doc 将本文的Word文档下载到电脑
搜索更多关于: 算法与数据结构实验 的文档
相关推荐
相关阅读