我是Go的新學習者,這些問題困擾了我很多。我解決不了他們,你們能幫我一把嗎?GO中的函數體錯誤之外的非聲明語句
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
的錯誤顯示:
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 }
我不明白爲什麼這些問題來?
Go中沒有'while'循環。用'for'改變它。 – tomasz
是的,我剛剛查看了教程並注意到了這一點。謝謝 –