有没有可能在不丢失头指针的情况上不用其他变量遍历一个单向链表

有没有可能在不丢失头指针的情况下不用其他变量遍历一个单向链表
如题。。。。。。有没有可能在不丢失头指针的情况上不用其他变量遍历一个单向链表有没有可能在不丢失头指针的情况上不用其他变量遍历一个单向链表有没有可能在不丢失头指针的情况上不用其他变量遍历一个单向链表有没有可能在不丢失头指针的情况上不用其他变量遍历一个单向链表
------解决方案--------------------
引用:
引用:C/C++ code
?



1234567891011121314

struct Node {     int Value;     Node*pNext; };   void func( Node* p ) {     if( p )     {         printf( "%d\n",p->Value); ……

那就利用一下返回值呗,递归一下将最后的节点返回,.



struct Node
{
    int Value;
    Node*pNext;
};
 
void func( Node* p )
{
    if( p->next )
    {
        return func( p->pNext );
    }
    else
    {
        return p;
    }
}

Node*p = .....;
func( p )->next = p;