⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jay1.c

📁 有关数据结构的一些例子。用C语言编写的。非常有价值的程序。对初学者有指导借鉴意义。
💻 C
字号:
#define NULL 0
#include "stdio.h"
#include "malloc.h"
typedef int datatype;
typedef struct dnode
{ datatype data;
  struct dnode *prior,*next;
} dlinklist;
dlinklist *head,*l;

dlinklist *CREAT()
{ int ch;
  dlinklist *h,*s,*r;
  h=(struct dnode *)malloc(sizeof(dlinklist));
  r=h;
  printf("\ndlinklist:\n");
  scanf("%d",&ch);
  while(ch!=0)
  { s=(struct dnode *)malloc(sizeof(dlinklist));
    s->data=ch;
    r->next=s;
    r=s;
    printf("%d\t",s->data);
    scanf("%d",&ch);
  }
  r->next=NULL;
 return(h);
}

INSERT(x)
datatype x;
{ dlinklist *s;
  s=(struct dnode *)malloc(sizeof(dlinklist));
  s->data=x;
  s->prior=head->prior;
  s->next=head;
  head->prior->next=s;
  head->prior=s;
}

DELETE(p)
dlinklist *p;
{
  p->prior->next=p->next;
  p->next->prior=p->prior;
  free(p);
}

main()
{ int m;
  head=CREAT();
  printf("\nINSERT:\n");
  scanf("%d",&m);
  INSERT(head,m);
  while(head!=NULL)
  { printf("%d\t",head->next->data);
    head=head->next;
  }
  printf("\nDELETE:\n");
  scanf("%d",l->data);
  DELETE(l);
  while(head!=NULL)
  { printf("%d\t",head->next->data);
    head=head->next;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -