Change the operations sequence of the likedlist's insert() method.
This commit is contained in:
parent
18f2ec4fdc
commit
9ea24e8b26
@ -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 之后的首个结点 */
|
||||
|
@ -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 之后的首个结点 */
|
||||
|
@ -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 之后的首个结点 */
|
||||
|
@ -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 之后的首个结点 */
|
||||
|
@ -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 之后的首个结点 */
|
||||
|
@ -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 之后的首个结点 */
|
||||
|
@ -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 之后的首个结点 */
|
||||
|
@ -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):
|
||||
|
@ -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 之后的首个结点 */
|
||||
|
@ -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 之后的首个结点 */
|
||||
|
@ -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 之后的首个结点
|
||||
|
Loading…
x
Reference in New Issue
Block a user