链表
来源:互联网 发布:sql语句建立table 编辑:程序博客网 时间:2024/05/22 04:42
链表
#include<stdio.h>#include<stdlib.h>typedef struct node {int n;struct node *next;}sqlist;void init(sqlist *&l){l=(sqlist *)malloc(sizeof(sqlist));l->next=NULL;}void insert(sqlist *&l,int e){sqlist *p=l,*q;q=(sqlist *)malloc(sizeof(sqlist));q->n=e;q->next=p->next;p->next=q;}void delet(sqlist *&l ,int N,int &x){sqlist *p=l,*q;int j=0;while(j<N&&p->next){p=p->next;j++;}q=p->next;p->next=q->next;x=q->n;}void disp(sqlist *l){sqlist *q=l;q=q->next;while(q!=NULL){printf("%d ",q->n);q=q->next;}} int main(){sqlist *l ;init(l); int n,j,x; scanf("%d",&j) ; while(j--){scanf("%d",&n);insert(l,n); }disp(l); printf("\n");delet(l,2,x);printf("%d\n",x);disp(l);printf("\n");return 0;}
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 索引节点高速缓存
- Servelt + Jsp 的一个小示例
- Restful webservice 注意事项
- GlusterFS:分布式(Distribute )源码分析
- 伤感日志_茫茫天涯走遍,寂寞心酸
- 链表
- Main函数中参数argc,argv说明
- android异常之都是deamon惹的祸The connection to adb is down, and a severe error has occured.
- 个人所得税计算器
- 多边形的平滑(geomagic)
- 利息计算器
- 第9周-本月有几天?两种方法
- 约瑟夫环的变形
- 数据挖掘中易犯的十大错误