update book code

This commit is contained in:
Unknwon
2015-03-03 12:25:25 -05:00
parent b8c82ba4e5
commit eab1d98ba8
465 changed files with 15392 additions and 1572 deletions

View File

@@ -0,0 +1,45 @@
// Q15.go
package main
import (
"fmt"
"./stack/stack"
)
func main() {
st1 := new(stack.Stack)
fmt.Printf("%v\n", st1)
st1.Push(3)
fmt.Printf("%v\n", st1)
st1.Push(7)
fmt.Printf("%v\n", st1)
st1.Push(10)
fmt.Printf("%v\n", st1)
st1.Push(99)
fmt.Printf("%v\n", st1)
p := st1.Pop()
fmt.Printf("Popped %d\n", p)
fmt.Printf("%v\n", st1)
p = st1.Pop()
fmt.Printf("Popped %d\n", p)
fmt.Printf("%v\n", st1)
p = st1.Pop()
fmt.Printf("Popped %d\n", p)
fmt.Printf("%v\n", st1)
p = st1.Pop()
fmt.Printf("Popped %d\n", p)
fmt.Printf("%v\n", st1)
}
/* Output:
[0:3]
[0:3] [1:7]
[0:3] [1:7] [2:10]
[0:3] [1:7] [2:10] [3:99]
Popped 99
[0:3] [1:7] [2:10]
Popped 10
[0:3] [1:7]
Popped 7
[0:3]
Popped 3
*/