/**
* struct ListNode {
* int val;
* struct ListNode *next;
* ListNode(int x) :
* val(x), next(NULL) {
* }
* };
*/
class Solution {
public:
vector<int> printListFromTailToHead(ListNode* head) {
ListNode *p=head;
vector<int>v;
while(p!=NULL){
v.emplace_back(p->val);
p=p->next;
}
reverse(v.begin(),v.end());
return v;
}
};