切片-参考答案

2018-06-18  本文已影响0人  tonyemail_st
package main

import (
    "fmt"
)

func main(){


    twoD := make([][]int, 3)
    for i := 0; i<3; i++ {
        innerlen := i+1
        twoD[i] = make([]int, innerlen)
        for j := 0; j< innerlen; j++{
            twoD[i][j] = i+j
        }
    }
    fmt.Println(twoD)
}
上一篇下一篇

猜你喜欢

热点阅读