标签:cto code log str off vector null span blog
/** * struct ListNode { * int val; * struct ListNode *next; * ListNode(int x) : * val(x), next(NULL) { * } * }; */ class Solution { public: vector<int> printListFromTailToHead(ListNode* head) { int jiediangeshu = 0; ListNode* cur = head; vector<int> re; while (cur != NULL) { ++jiediangeshu; cur = cur->next; } for (int i = (jiediangeshu - 1); i >= 0; --i) { ListNode* temp = head; int x=i; while (x>0) { temp = temp->next; --x; } re.push_back(temp->val); } return re; } };
标签:cto code log str off vector null span blog
原文地址:http://www.cnblogs.com/159269lzm/p/7260671.html