mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:21:38 +08:00
update book code
This commit is contained in:
29
eBook/exercises/chapter_11/main_stack.go
Executable file
29
eBook/exercises/chapter_11/main_stack.go
Executable file
@@ -0,0 +1,29 @@
|
||||
// main_stack.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"./stack/stack"
|
||||
)
|
||||
|
||||
var st1 stack.Stack
|
||||
|
||||
func main() {
|
||||
st1.Push("Brown")
|
||||
st1.Push(3.14)
|
||||
st1.Push(100)
|
||||
st1.Push([]string{"Java", "C++", "Python", "C#", "Ruby"})
|
||||
for {
|
||||
item, err := st1.Pop()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
fmt.Println(item)
|
||||
}
|
||||
}
|
||||
/* Output:
|
||||
[Java C++ Python C# Ruby]
|
||||
100
|
||||
3.14
|
||||
Brown
|
||||
*/
|
Reference in New Issue
Block a user