链表反转
来源:互联网 发布:licecap mac版 编辑:程序博客网 时间:2024/06/06 15:41
void reverse(Node*& head){if(head==NULL)return ;Node* pre,*cur,*p;pre=head;cur=head->next;while(cur){p=cur->next;cur->next=pre;pre=cur;cur=p;}head->next=NULL;head=pre;}Node* reverse(Node* p,Node* &head){if (p==NULL||p->next==NULL){head->next=0;head=p;return p;}Node* temp=reverse(p->next,head);temp->next=p;return p; }void main(){Node* head,*p;int temp;head=new Node(); p=head;while (cin>>temp){ Node* cur=new Node(temp); p->next=cur;p=cur; } cin.clear(); p=head->next; //reverse(p); Node* q=reverse(p,p); while(p) { cout<<p->data<<" "; p=p->next; } cin.get();}
反转链表_递归与非递归
链表反转 递归和非递归版
单向链表的反转- 链表反转
- 反转链表
- 单向链表反转
- 链表反转:
- 链表的反转
- 链表反转
- 反转单向链表
- 链表反转
- 单向链表反转
- 单向链表反转
- 链表的反转
- 链表反转
- 反转链表
- 链表反转
- 链表反转
- 链表反转
- 链表反转
- 链表的反转
- css之FILTER:progid:DXImageTransform.Microsoft.Gradient使用
- python 日志分析
- 关于CCTMXTiledMap 获得整体地图的宽高
- 关于malloc和free函数的用法
- ORA-20200: End Snapshot Id 2 does not exist for this database/instance
- 链表反转
- 用 IIS 7、ARR 與 Velocity 建设高性能的大型网站
- struts2的工作原理--浅谈
- 背景圆角以及图片圆角处理
- Do not hardcode "/sdcard/"
- Android APK反编译详解(附图)
- IOS开发 textField 键盘遮挡问题
- 也扯内存泄露
- oracle查询排序asc/desc 多列 order by