/**
* 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> v;//调用默认构造函数初始化
while(head!=NULL)
{
v.push_back(head->val);
head = head->next;
}
//用v的[ begin(), end() )区间中的元素(左闭右开)反向初始化新vector
return vector<int>(v.rbegin(), v.rend());
}
};