//从尾到头打印链表
struct ListNode
{
string key;
ListNode* next;
};
bool printlistreversingly(ListNode* pHead)
{
if (pHead==NULL) {
return false;
}
stack<string> sk;
while (pHead!=NULL) {
sk.push(pHead->key);
pHead=pHead->next;
}
while (sk.empty()==0) {
printf("%s\n",sk.top().c_str());
sk.pop();
}
return true;
}
剑指off-从尾到头打印
最新推荐文章于 2015-08-21 16:01:04 发布