*  struct ListNode {
*        int val;
*        struct ListNode *next;
*        ListNode(int x) :
*              val(x), next(NULL) {
*        }
*  };
*/
class Solution {
public:
    vector<int> printListFromTailToHead(ListNode* head) {
        //使用c++动态数组存储
        vector<int> result;
        ListNode *p=head;
        while(p!=NULL){
           
            result.push_back(p->val);
            p=p->next;
        }
        //c++实现vector反转
        reverse(result.begin(),result.end());
        return result;
        
    }
};