目录
- 链表的从尾到头打印(递归)
链表的从尾到头打印(递归)
递归打印链表
#include <bits/stdc++.h>
using namespace std;void coutls(list<int>::iterator iter, list<int>::iterator node_end){if (iter!=node_end){coutls(++iter, node_end);cout << *(--iter) << " ";}
}int main( )
{list<int> node;for (int i = 1; i < 10; i++){node.push_back(i);}auto it = node.begin();coutls(it, node.end());// it = node.begin();// while (it!=node.end())// {// cout<< *it <<endl;// it++;// }return 0;
}