C/C++双链表正排序
来源:互联网 发布:国际淘宝什么意思 编辑:程序博客网 时间:2024/05/18 13:42
- #include<stdio.h>
- #include<stdlib.h>
- #include<malloc.h>
- struct list{
- int data;
- struct list *next;
- struct list *pre;
- };
- typedef struct list node;
- typedef node *link;
- link front=NULL,rear,ptr,head=NULL;
- link push(int item){
- link newnode=malloc(sizeof(node));
- newnode->data=item;
- if(head==NULL)
- {
- head=newnode;
- head->next=NULL;
- head->pre=NULL;
- rear=head;
- }
- else
- {
- rear->next=newnode;
- newnode->pre=rear;
- newnode->next=NULL;
- rear=newnode;
- }
- return head;
- }
- void makenull(){
- front=NULL;
- rear=NULL;
- }
- empty(){
- if(front==NULL)
- return 1;
- else
- return 0;
- }
- int tops(){
- if(empty())
- return NULL;
- else
- return rear->data;
- }
- void pop(){
- if(empty())
- printf("stack is empty!/n");
- else
- rear=rear->pre;
- }
- void display(link l){
- link p;
- p=l;
- while(p!=NULL){
- printf("%d->",p->data);
- p=p->next;
- }
- }
- void main(){
- int n,i;
- printf("input your first data!/n");
- scanf("%d",&n);
- front=push(n);
- /*another data*/
- for(i=0;i<3;i++)
- {
- printf("input:/n");
- scanf("%d",&n);
- push(n);
- }
- ptr=front;
- display(ptr);
- printf("/n Please enter any key to pop");
- getch();
- pop();
- ptr=front;
- display(ptr);
- getch();
- }
<script type="text/javascript"><!--google_ad_client = "pub-3555979289815451";google_ad_slot = "0437120238";google_ad_width = 468;google_ad_height = 60;//--></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
- C/C++双链表正排序
- c/c++双链表正排序
- c/c++双链表正排序
- 排序(C)
- C排序
- C++------------------------------------------------------------- 排序
- C/C++--set排序
- 归并排序(C/C++)
- 插入排序(C/C++)
- 【C/C++】排序总结
- 排序-快速排序(c)
- 排序算法实现(C/C++)
- C语言、C++:快速排序
- C/C++——排序
- 排序算法汇总(C/C++)
- 堆排序(C\C++)
- 排序算法之冒泡排序(C/C++)
- 排序算法之希尔排序(C/C++)
- C/C++小写数字转换成大写数字
- 窗口破坏过程与Windows消息循环
- 多核中的并行前缀和计算
- cssFloat、styleFloat,currentStyle、document.defaultView.getComputedStyle
- 一步一步搭建免费的Silverlight 2开发环境
- C/C++双链表正排序
- 微软,您的.net为中国程序员带来了什么?
- C/C++二叉排序树
- .net(ADO.NET)数据库研究(1):部分主要类及类关系探秘
- C/C++线性顺序存储结构
- 被裁后,找工历程
- 关于JSP页面中的pageEncoding和contentType两种属性的区别
- 中文保存出现乱码
- strlen与sizeof的区别