C++ 代码
/**
* 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;
while(head)
{
a.push_back(head->val);
head = head->next;
}
return vector<int>(a.rbegin(), a.rend());
}
};