Talk is cheap,show me the code.
func fibonacci(n int, c chan int) {
x, y := 0, 1
for i := 0; i < n; i++ {
c <- x
x, y = y, x+y
}
close(c)
}
Talk is cheap,show me the code.
func fibonacci(n int, c chan int) {
x, y := 0, 1
for i := 0; i < n; i++ {
c <- x
x, y = y, x+y
}
close(c)
}
本文标题:Go使用通道实现 斐波那契数列
本文链接:https://www.haomeiwen.com/subject/ewptwctx.html
网友评论