go语言 基础 求解答

wwwmmm 发布于 2012/12/17 10:45
阅读 524
收藏 0
Go
package main

import "fmt"

func main(){

	var arr [3]int

	arr[0] = 42
	arr[1] = 13

	fmt.Print("first is %d\n", arr[0])
	fmt.Print("second is %d\n", arr[1])
}
运行结果如下:

正确的不是应该是

first is 42

second is 13



helloworld:~/go/src/mathapp$ go build
helloworld:~/go/src/mathapp$ ls
main.go  mathapp
helloworld:~/go/src/mathapp$ ./mathapp
first is %d
42second is %d
13helloworld:~/go/src/mathapp$
加载中
0
剑尖血凝紫
剑尖血凝紫
该评论暂时无法显示,详情咨询 QQ 群:点此入群
0
滔滔下载站
滔滔下载站
不是fmt.Print,应该用fmt.Printf
0
剑尖血凝紫
剑尖血凝紫
该评论暂时无法显示,详情咨询 QQ 群:点此入群
0
wwwmmm
wwwmmm

引用来自“过儿”的答案

fmt.Printf("first is %d\n", arr[0])
fmt.Printf("second is %d\n", arr[1])
唉  眼神越来越不好使了,  检查了好几遍  楞是没看出来
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部