/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
* 剑指 Offer 06. 从尾到头打印链表
*/
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int b[10005]={-1000};
int c[10005]={-1000};
int len=0;
int* reversePrint(struct ListNode* head, int* returnSize){
//returnSize=b;
while(head!=NULL)
{
c[len++]=head->val;
head=head->next;
}
*returnSize=len;
int i=0,j=0;
for(i=0;i<len;i++)
{
b[i]=c[len-i-1];
}
return b;
}
逆序输出链表相关问题
最新推荐文章于 2022-10-13 00:37:23 发布