mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-11-13 09:16:10 +08:00
fix: coding style and file format for chapter 9.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"container/list"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -17,6 +17,7 @@ func main() {
|
||||
fmt.Println(e.Value)
|
||||
}
|
||||
}
|
||||
|
||||
/* Example output:
|
||||
&{0x12542bc0 <nil> 0x12547590 1}
|
||||
&{0x12542ba0 0x12542be0 0x12547590 2}
|
||||
|
||||
@@ -18,7 +18,8 @@ func Fibonacci(op string, n int) (res int) {
|
||||
res = 1
|
||||
case "*":
|
||||
res = 2
|
||||
default: res = 0
|
||||
default:
|
||||
res = 0
|
||||
}
|
||||
} else {
|
||||
switch op {
|
||||
@@ -26,7 +27,8 @@ func Fibonacci(op string, n int) (res int) {
|
||||
res = Fibonacci(op, n-1) + Fibonacci(op, n-2)
|
||||
case "*":
|
||||
res = Fibonacci(op, n-1) * Fibonacci(op, n-2)
|
||||
default: res = 0
|
||||
default:
|
||||
res = 0
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -24,4 +24,3 @@ func IsEvening() bool {
|
||||
localTime := time.Now()
|
||||
return localTime.Hour() <= 22
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"./fibo/fibo"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var nextFibo int
|
||||
@@ -40,6 +40,7 @@ func next() {
|
||||
result = fibo.Fibonacci(op, nextFibo)
|
||||
fmt.Printf("fibonacci(%d) is: %d\n", nextFibo, result)
|
||||
}
|
||||
|
||||
/* *****************************************************************
|
||||
Output is:
|
||||
fibonacci(1) is: 1
|
||||
@@ -58,5 +59,3 @@ fibonacci(3) is: 8
|
||||
...
|
||||
fibonacci(4) is: 32
|
||||
********************************************************************/
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"./greetings/greetings"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"./even/even"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -11,4 +11,5 @@ func main() {
|
||||
size := unsafe.Sizeof(i)
|
||||
fmt.Println("The size of an int is: ", size)
|
||||
}
|
||||
|
||||
// The size of an int is: 4
|
||||
|
||||
Reference in New Issue
Block a user