【剑指offer】——从尾到头打印链表

题目:

从尾到头打印链表

解答:

struct ListNode{
	int val;
	ListNode* next;
}

void PrintListR(ListNode* head)
{
	if(head!=NULL)
	{	
		if(head->next!=NULL)
		{
			PrintListR(head->next);
		}
		printf("%d\t",head->val);
	}
}

递归思想。

发布了160 篇原创文章 · 获赞 316 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/ShawnWang1994/article/details/99623652
今日推荐