blob: 7f556e6f732aacb472ae3dbc1a13293aa32d4de6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package main
import "fmt"
type node struct {
v int
next *node
}
func main() {
lista := new(node)
lista.next = nil
lista.carica(5)
for lista != nil {
fmt.Printf("%d ",lista.v)
lista = lista.next
}
}
func (head *node) carica(N int) {
if N < 1 {
return
}
for i := 0; i < N-1; i++ {
fmt.Scanf("%d", &head.v)
head.next = new(node)
head = head.next
}
fmt.Scanf("%d", &head.v)
head.next = nil
}
|