方法1:定义栈结构,遍历链表将值存在栈里面,然后再出栈打印 O(n)方法2:递归的本质也是栈,但是链表过长的话可能会造成内存溢出
void f1(ListNode * head){ if(head!=null) if(head->next!=null) f1(head->next); cout>>head.date>>endl; }