c/c++双链表正排序
来源:互联网 发布:微软的云计算系统 编辑:程序博客网 时间:2024/06/02 05:05
源于:http://blog.csdn.net/Mobidogs/archive/2008/11/30/3414624.aspx
- #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();
- }
- 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++)
- 返回JS
- JProfiler学习笔记
- Topcoder_157
- 中兴软创笔试题二
- 使用HttpURLConnection类(利用sessionId保持会话)
- c/c++双链表正排序
- oracle erp无法复制问题
- COBOL学习(2)-关键字和语法
- JAVA编程获取IP地址
- Teach Yourself Visual C++ 6 in 21 Days 001
- 一些常用的FUNCTION
- 中兴软创笔试题三
- word转tif格式的类文件
- 通过临时文件的方法把awk中的数组赋值给shell中的数组