fix print

This commit is contained in:
戴林峰 2022-12-24 15:39:38 +08:00
parent 29574378a6
commit e3988296dd
2 changed files with 16 additions and 8 deletions

View File

@ -3,10 +3,7 @@
// Author: dlfld (2441086385@qq.com)
package chapter_array_and_linkedlist
import (
"fmt"
"testing"
)
import "testing"
/* Driver Code */
func TestLinkedList(t *testing.T) {
@ -23,8 +20,5 @@ func TestLinkedList(t *testing.T) {
n2.Next = n3
n3.Next = n4
for n0 != nil{
fmt.Printf("%v ",n0.Val)
n0 = n0.Next
}
PrintLinkedList(n0)
}

View File

@ -0,0 +1,14 @@
// File: print_utils.go
// Created Time: 2022-12-24
// Author: dlfld (2441086385@qq.com)
package chapter_array_and_linkedlist
import "fmt"
func PrintLinkedList(head *ListNode){
for head != nil{
fmt.Printf("%v ",head.Val)
head = head.Next
}
}