2022-09-04:以下go语言代码输出什么?A:不能编译;B:45;C:45.2;D:45.0。 package main import ( “fmt“ ) func main() {
2022-09-04:以下go语言代码输出什么?A:不能编译;B:45;C:45.2;D:45.0。
package main
import (
"fmt"
)
func main() {
var ans float64 = 15 + 25 + 5.2
fmt.Println(ans)
}
答案选C。这道题有很多人选A。15 + 25 + 5.2在编译期间做处理。
公众号:福大大架构师每日一题