英文:
no result values expectedcompilerWrongResultCount
问题
我有这两个函数
func fib_memo(n int) {
memo := make([]int, n+1)
return fib_2(n, memo)
}
func fib_2(n int, memo []int) int {
result := 0
if &memo[n] != nil {
return memo[n]
}
if n == 1 || n == 2 {
result = 1
} else {
result = fib_2(n-1, memo) + fib_2(n-2, memo)
memo[n] = result
}
return result
}
但是第一个函数给我一个编译错误,我不知道为什么,请帮忙看看:no result values expectedcompilerWrongResultCount
英文:
I have this two functions
func fib_memo(n int) {
memo := make([]int, n+1)
return fib_2(n, memo)
}
func fib_2(n int, memo []int) int {
result := 0
if &memo[n] != nil {
return memo[n]
}
if n == 1 || n == 2 {
result = 1
} else {
result = fib_2(n-1, memo) + fib_2(n-2, memo)
memo[n] = result
}
return result
}
But the first in giving me a compiler error i don't no why please help : no result values expectedcompilerWrongResultCount
答案1
得分: -1
func fib_memo(n int) (result int) {
memo := make([]int, n+1)
return fib_2(n, memo)
}
英文:
func fib_memo(n int) (result int) {
memo := make([]int, n+1)
return fib_2(n, memo)
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论