反转链表
来源:互联网 发布:网络实体小说排行榜 编辑:程序博客网 时间:2024/05/17 20:29
//定义一个函数,输入一个链表的头结点,反转该链表并输出反转后链表的头结点。#include "stdlib.h"struct ListNode{int m_nKey;ListNode* m_pNext;};ListNode* ReverseList(ListNode* pHead){if (pHead == NULL || pHead->m_pNext == NULL)return pHead;ListNode* current = pHead->m_pNext;ListNode* currentAhead = pHead;ListNode* currentBehind = current->m_pNext;current->m_pNext = currentAhead;currentAhead->m_pNext = NULL;while (currentBehind != NULL){currentAhead = current;current = currentBehind;currentBehind = current->m_pNext;current->m_pNext = currentAhead;}return current;}
0 0
- 链表反转
- 反转链表
- 单向链表反转
- 链表反转:
- 链表的反转
- 链表反转
- 反转单向链表
- 链表反转
- 单向链表反转
- 单向链表反转
- 链表的反转
- 链表反转
- 反转链表
- 链表反转
- 链表反转
- 链表反转
- 链表反转
- 链表的反转
- 软件的版本标志
- linux 发送邮件
- JAVA设计模式(10):结构型-组合模式(Composite)
- Collection NSArrayM was mutated while being enumerated
- Nginx linux服务搭建
- 反转链表
- activiti简介
- 51nod 1118 机器人走方格(简单DP)
- POJ 3070 Fibonacci(矩阵快速幂)
- AR与VR初探
- c语言文件操作总结
- java中关于小数的四舍五入问题
- hdu1081 To The Max 「dp」
- 第9周项目1-深复制体验(2)