关于单链表
来源:互联网 发布:易语言自动关机源码 编辑:程序博客网 时间:2024/05/17 08:53
#include <iostream>#include <string>using namespace std;//int Er_fen(int A[],int length,int data)//{//int begin=0;//int end=length-1;//while (begin<=end)//{//int midle=(begin+end)/2;//if (data==A[midle])//return midle;//else if(data>A[midle])//begin=midle+1;//else// end=midle-1;////}//return -1;//}//union //{//int i;//char x[2];////}a;//int fun_(int n)//{////if (n==0||n==1)//{//return 1;//}//else//{//return n*fun_(n-1);//}//}struct LinkNode{int data;LinkNode* next;};void Print_(LinkNode* &head){ LinkNode* p=head->next;while (p!=NULL){cout<<p->data;p=p->next;}}LinkNode* Fanzhuan_(LinkNode* &head){if(head->next==NULL||head->next->next==NULL)return head;LinkNode* s=NULL;LinkNode* p=head->next;LinkNode* q=head->next->next;while (q){s=q->next;q->next=p;p=q;q=s;}head->next->next=NULL;head->next=p;return head;}LinkNode* DeLe_(LinkNode* head,int i){if (head==NULL)return NULL;LinkNode* p=head->next;int count=1;while(p&&count!=i-1){count++;p=p->next;}LinkNode* q=p->next;p->next=q->next;delete q;return head;}LinkNode* Insert(LinkNode* head,int i,int data){if (head->next==NULL) return head;LinkNode* p=head->next;int count=1;while(p&&count!=i){count++;p=p->next;}LinkNode* pNew=new LinkNode;pNew->data=data;pNew->next=p->next;p->next=pNew;return head;}int main(){/*int A[8]={1,2,4,5,7,8,9,10};int i=0;int t=Er_fen(A,8,7);if (t==-1){cout<<"没找到!";}else{cout<<"下标是"<<t<<endl;}cout<<++t+2;*//*int m,n;cin>>n;m=fun_(n);cout<<m;return 1;*/LinkNode* head;head=new LinkNode;head->data=-1;head->next=NULL;LinkNode* p,*q;p=head;for (int i=0;i<10;++i){q=new LinkNode;q->data=i;q->next=NULL;p->next=q;p=q;}head=Fanzhuan_(head);//head=Insert(head,5,6);head=DeLe_(head,5);Print_(head);}
0 0
- 关于单链表
- 关于单链表
- 关于单链表
- 关于单链表
- 关于单链表的操作
- 关于单链表的练习
- 关于单链表的几道题
- 关于合并有序单链表
- 关于单链表的基础知识
- 关于单链表的理解
- 关于
- 关于
- 关于++,--
- 关于#
- 关于。。。
- 关于
- 关于......
- 关于
- 在一个文件中有 10G 个整数,乱序排列,要求找出中位数。内存限制为 2G。
- NSURLRequest Class Reference
- ClientIDMode,ViewStateMode 详解
- Netty In Action中文版 - 第三章:Netty核心概念
- ubuntu驱动开发环境搭建之nfs
- 关于单链表
- numpy基本方法总结
- oracle 触发器的种类和触发事件
- android 数据库基础用法
- SAP BO 技术
- 基本知识
- error:jquery 用$.post 传递给php页面值时,没有返回
- DirectoryIndex 详解
- HDU 1044 Collect More Jewels