doukui4836
2015-11-17 13:59
浏览 101
已采纳

GO中函数体外错误的非声明语句

I am a new learner with Go, and these problems confused me a lot. I cannot solve them, could you guys give me a hand?

func Solution(A []int, B[]int, K int) int{
.......
res = MaxInt32 
low = 0
high = Min(900, largestId) //largestId is limited here
mid = 0

while(low <= high){
    mid = {low + high} / 2         55
    if(isAvailable(K, mid)){
        res := Min(res, mid)
        high :=mid - 1
    } else{
        low := mid + 1
    }

}
return res                         64
}                                  65

The errors show:

workspace/src/solution/solution.go:55: syntax error: unexpected =, expecting }
workspace/src/solution/solution.go:64: non-declaration statement outside function body
workspace/src/solution/solution.go:65: syntax error: unexpected }

I don't understand why these problems come?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题