我想如何在布尔变量和函数调用之间进行逻辑运算“或”
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评估为false,而将其他任何数值评估为true,则可以执行以下操作:
possiblemove = possiblemove || Move( x+2, y+1, m+1) != 0
关于function - 在Golang中如何在 boolean 变量和以整数作为参数的函数之间进行逻辑运算,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39250007/