【面试题】剑指offer 5
来源:互联网 发布:js文件调用java代码 编辑:程序博客网 时间:2024/05/18 01:21
输入一个链表的头结点,从尾到头打印链表
#include<iostream>#include<assert.h>using namespace std;class ListNode{public:ListNode(const int & x):_value(x),_next(NULL){}int _value;ListNode* _next;};class List{public:List():head(NULL){}void pushTail(const int& key){if(head==NULL)head=new ListNode(key);else{ListNode* node=head;while (node->_next!=NULL){node=node->_next;}node->_next=new ListNode(key);}}void printTail(ListNode* head){if(head!=NULL){if(head->_next!=NULL){//printTail();printTail(head->_next);}printf("%d ",head->_value);}printf("\n");}public:ListNode* head;};int main(){List list;list.pushTail(1);list.pushTail(2);list.pushTail(3);list.pushTail(4);list.pushTail(5);ListNode* node=list.head; list.printTail(node);system("pause");return 0;}
0 0
- 剑指offer面试题5
- 剑指offer 面试题5
- 剑指offer-面试题5
- 【面试题】剑指offer 5
- 剑指offer 面试题
- 剑指offer面试题
- 剑指Offer面试题5 Java解法
- 剑指Offer(面试题3~5)
- 剑指offer--面试题5:替换空格
- 【剑指offer】面试题 5:替换空格
- 【剑指offer】面试题5:替换空格
- 剑指offer 面试题5: 替换空格
- 剑指offer面试题总结
- 剑指offer面试题06
- 剑指offer面试题 04
- 剑指offer 面试题07
- 剑指offer面试题08
- 剑指offer面试题42
- 1122. Hamiltonian Cycle (25) PAT 甲级
- 运算符重载-赋值运算符的重载
- Intellij idea 和myeclipse的最常用快捷键
- 空包签名
- Tomcat启动过程原理详解
- 【面试题】剑指offer 5
- 百年地震数据告诉你,哪里的房子不能买
- equals 和 == 的区别
- “区块链”究竟是什么,怎么理解?
- 关于Activity的四大启动模式
- Java 内存模型及GC原理
- PAT 1021
- mysql唯一索引失效原因分析
- 测试使用