/
* 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;
stack<int> st;
for (ListNode* p = head;p!=NULL;p=p->next){
int k = p->val;
st.push(k);
}
while(!st.empty()){
int k = st.top();
st.pop();
v.push_back(k);
}
return v;
}
};