diff --git a/codes/c/chapter_array_and_linkedlist/linked_list.c b/codes/c/chapter_array_and_linkedlist/linked_list.c index 94bbe3a50..c414e1b64 100644 --- a/codes/c/chapter_array_and_linkedlist/linked_list.c +++ b/codes/c/chapter_array_and_linkedlist/linked_list.c @@ -9,8 +9,8 @@ /* 在链表的结点 n0 之后插入结点 P */ void insert(ListNode* n0, ListNode* P) { ListNode *n1 = n0->next; - n0->next = P; P->next = n1; + n0->next = P; } /* 删除链表的结点 n0 之后的首个结点 */ diff --git a/codes/cpp/chapter_array_and_linkedlist/linked_list.cpp b/codes/cpp/chapter_array_and_linkedlist/linked_list.cpp index 3e457891c..8392fcb5c 100644 --- a/codes/cpp/chapter_array_and_linkedlist/linked_list.cpp +++ b/codes/cpp/chapter_array_and_linkedlist/linked_list.cpp @@ -9,8 +9,8 @@ /* 在链表的结点 n0 之后插入结点 P */ void insert(ListNode* n0, ListNode* P) { ListNode* n1 = n0->next; - n0->next = P; P->next = n1; + n0->next = P; } /* 删除链表的结点 n0 之后的首个结点 */ diff --git a/codes/csharp/chapter_array_and_linkedlist/linked_list.cs b/codes/csharp/chapter_array_and_linkedlist/linked_list.cs index 68e0d4671..6ca3f141d 100644 --- a/codes/csharp/chapter_array_and_linkedlist/linked_list.cs +++ b/codes/csharp/chapter_array_and_linkedlist/linked_list.cs @@ -13,8 +13,8 @@ public class linked_list public static void insert(ListNode n0, ListNode P) { ListNode? n1 = n0.next; - n0.next = P; P.next = n1; + n0.next = P; } /* 删除链表的结点 n0 之后的首个结点 */ diff --git a/codes/dart/chapter_array_and_linkedlist/linked_list.dart b/codes/dart/chapter_array_and_linkedlist/linked_list.dart index 00efdfc4d..2edd86da3 100644 --- a/codes/dart/chapter_array_and_linkedlist/linked_list.dart +++ b/codes/dart/chapter_array_and_linkedlist/linked_list.dart @@ -12,8 +12,8 @@ class LinkedList { /* 在链表的结点 n0 之后插入结点 P */ void insert(ListNode n0, ListNode P) { ListNode? n1 = n0.next; - n0.next = P; P.next = n1; + n0.next = P; } /* 删除链表的结点 n0 之后的首个结点 */ diff --git a/codes/go/chapter_array_and_linkedlist/linked_list.go b/codes/go/chapter_array_and_linkedlist/linked_list.go index 8a60fd18e..26a1d6c02 100644 --- a/codes/go/chapter_array_and_linkedlist/linked_list.go +++ b/codes/go/chapter_array_and_linkedlist/linked_list.go @@ -11,8 +11,8 @@ import ( /* 在链表的结点 n0 之后插入结点 P */ func insertNode(n0 *ListNode, P *ListNode) { n1 := n0.Next - n0.Next = P P.Next = n1 + n0.Next = P } /* 删除链表的结点 n0 之后的首个结点 */ diff --git a/codes/java/chapter_array_and_linkedlist/linked_list.java b/codes/java/chapter_array_and_linkedlist/linked_list.java index 0db8f6ae7..64a41ed18 100644 --- a/codes/java/chapter_array_and_linkedlist/linked_list.java +++ b/codes/java/chapter_array_and_linkedlist/linked_list.java @@ -12,8 +12,8 @@ public class linked_list { /* 在链表的结点 n0 之后插入结点 P */ static void insert(ListNode n0, ListNode P) { ListNode n1 = n0.next; - n0.next = P; P.next = n1; + n0.next = P; } /* 删除链表的结点 n0 之后的首个结点 */ diff --git a/codes/javascript/chapter_array_and_linkedlist/linked_list.js b/codes/javascript/chapter_array_and_linkedlist/linked_list.js index 6c5ef8b9d..334990b4b 100644 --- a/codes/javascript/chapter_array_and_linkedlist/linked_list.js +++ b/codes/javascript/chapter_array_and_linkedlist/linked_list.js @@ -10,8 +10,8 @@ const { ListNode } = require("../include/ListNode"); /* 在链表的结点 n0 之后插入结点 P */ function insert(n0, P) { const n1 = n0.next; - n0.next = P; P.next = n1; + n0.next = P; } /* 删除链表的结点 n0 之后的首个结点 */ diff --git a/codes/python/chapter_array_and_linkedlist/linked_list.py b/codes/python/chapter_array_and_linkedlist/linked_list.py index 4fb6b1ba5..a6dce0c2e 100644 --- a/codes/python/chapter_array_and_linkedlist/linked_list.py +++ b/codes/python/chapter_array_and_linkedlist/linked_list.py @@ -11,8 +11,8 @@ from include import * """ 在链表的结点 n0 之后插入结点 P """ def insert(n0, P): n1 = n0.next - n0.next = P P.next = n1 + n0.next = P """ 删除链表的结点 n0 之后的首个结点 """ def remove(n0): diff --git a/codes/swift/chapter_array_and_linkedlist/linked_list.swift b/codes/swift/chapter_array_and_linkedlist/linked_list.swift index 90218b26b..d36442035 100644 --- a/codes/swift/chapter_array_and_linkedlist/linked_list.swift +++ b/codes/swift/chapter_array_and_linkedlist/linked_list.swift @@ -9,8 +9,8 @@ import utils /* 在链表的结点 n0 之后插入结点 P */ func insert(n0: ListNode, P: ListNode) { let n1 = n0.next - n0.next = P P.next = n1 + n0.next = P } /* 删除链表的结点 n0 之后的首个结点 */ diff --git a/codes/typescript/chapter_array_and_linkedlist/linked_list.ts b/codes/typescript/chapter_array_and_linkedlist/linked_list.ts index a5c49e8e4..793998043 100644 --- a/codes/typescript/chapter_array_and_linkedlist/linked_list.ts +++ b/codes/typescript/chapter_array_and_linkedlist/linked_list.ts @@ -10,8 +10,8 @@ import { printLinkedList } from '../module/PrintUtil'; /* 在链表的结点 n0 之后插入结点 P */ function insert(n0: ListNode, P: ListNode): void { const n1 = n0.next; - n0.next = P; P.next = n1; + n0.next = P; } /* 删除链表的结点 n0 之后的首个结点 */ diff --git a/codes/zig/chapter_array_and_linkedlist/linked_list.zig b/codes/zig/chapter_array_and_linkedlist/linked_list.zig index f0b1a2122..0e56c88b4 100644 --- a/codes/zig/chapter_array_and_linkedlist/linked_list.zig +++ b/codes/zig/chapter_array_and_linkedlist/linked_list.zig @@ -8,8 +8,8 @@ const inc = @import("include"); // 在链表的结点 n0 之后插入结点 P pub fn insert(n0: ?*inc.ListNode(i32), P: ?*inc.ListNode(i32)) void { var n1 = n0.?.next; - n0.?.next = P; P.?.next = n1; + n0.?.next = P; } // 删除链表的结点 n0 之后的首个结点