2023-01-09:以下go语言代码输出什么?A:+Inf; B:zero; C:something else; D:doesn‘t compile。 package main import (
Posted 福大大架构师每日一题
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2023-01-09:以下go语言代码输出什么?A:+Inf; B:zero; C:something else; D:doesn‘t compile。 package main import (相关的知识,希望对你有一定的参考价值。
2023-01-09:以下go语言代码输出什么?A:+Inf; B:zero; C:something else; D:doesn’t compile。
package main
import (
"fmt"
"math"
)
func main()
// Inf returns positive infinity if sign >= 0, negative infinity if sign < 0.
x := math.Inf(1)
switch
case x < 0, x > 0:
fmt.Println(x)
case x == 0:
fmt.Println("zero")
default:
fmt.Println("something else")
答案选A。这道题考的不是语法,而是英语。根据注释 Inf returns positive infinity if sign >= 0, negative infinity if sign < 0.,即可得出答案。
以上是关于2023-01-09:以下go语言代码输出什么?A:+Inf; B:zero; C:something else; D:doesn‘t compile。 package main import (的主要内容,如果未能解决你的问题,请参考以下文章