我想如何进行逻辑操作" OR"在布尔变量和函数调用之间
func Move(x int, y int, m int) int{
if IsvisitedNode(x,y){
var possiblemove bool
possiblemove = possiblemove || Move( x+2, y+1, m+1)
possiblemove = possiblemove || Move( x+2, y-1, m+1)
possiblemove = possiblemove || Move( x-2, y+1, m+1)
possiblemove = possiblemove || Move( x-2, y-1, m+1)
possiblemove = possiblemove || Move( x+1, y+2, m+1)
possiblemove = possiblemove || Move( x+1, y-2, m+1)
possiblemove = possiblemove || Move( x-1, y+2, m+1)
possiblemove = possiblemove || Move( x-1, y-2, m+1)
if possiblemove == true {
fmt.Println(x,y)
return true
}else{
visithistory[p] && visithistory[q] = false
return false
}
}
return 1
}
有人可以帮帮我吗?
答案 0 :(得分:0)
假设您想要将0评估为false,而将任何其他数字评估为true,则可以执行以下操作:
possiblemove = possiblemove || Move( x+2, y+1, m+1) != 0