从尾到头打印链表
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
vector<int> printListReversingly(ListNode* head) {
vector<int> a;
if(head == NULL){
return a;
}else{
a = printListReversingly(head -> next);
a.push_back(head -> val);
return a;
}
}
};