用户工具

站点工具


链表

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
链表 [2025/12/10 15:15]
113.44.126.199 已恢复为旧版 (2025/11/24 07:18)
链表 [2026/01/27 16:27] (当前版本)
116.204.64.97 已恢复为旧版 (2025/12/07 15:11)
行 1: 行 1:
  
- +
   定义链表    定义链表 
-  
   class ListNode {    class ListNode { 
-    public $val = NULL;  +     public $val = NULL;  
-    public $next = NULL; +     public $next = NULL; 
    function __construct($val = 0, $next = null) {    function __construct($val = 0, $next = null) {
            $this->val = $val;            $this->val = $val;
            $this->next = $next;            $this->next = $next;
       }       }
-   }+  } 
 +    
 +    
   class LinkList {    class LinkList { 
      public $next=null;      public $next=null;
行 25: 行 27:
         }          } 
     }     }
-  public function insert_arr($arr = array() ) { +   public function insert_arr($arr = array() ) { 
        foreach($arr as $val){        foreach($arr as $val){
           $this->insert($val);             $this->insert($val);  
        }        }
    
-    +     
-    public function display() {  +  public function display() {  
-      echo "当前链表的是: <br/>"; +  echo "当前链表的是: <br/>"; 
         $currentNode = $this->next;          $currentNode = $this->next; 
         while ($currentNode !== NULL) {          while ($currentNode !== NULL) { 
/home/minxuanbm4ipnyxlu3ann/wwwroot/dokuwiki/data/attic/链表.1765350959.txt.gz · 最后更改: 2025/12/10 15:15 由 113.44.126.199