\u5f15\u8a00<\/strong><\/span><\/div>\n\u4e4b\u524d\uff0c\u5237Leetcode\u7684\u65f6\u5019\uff0c\u6709\u4e9b\u9898\u9700\u8981\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4\uff0c\u800c\u4e00\u7ef4\u6570\u7ec4\u7684\u521d\u59cb\u5316\uff0c\u6bd4\u5982\uff1a<\/p>\n
\r\nvar a = [5]int{1, 2, 3, 4, 5} \/\/ \u7528var\r\nb := [5]int{1, 2, 3, 4, 5} \/\/ \u7528\u7c7b\u578b\u63a8\u65ad\r\nvar c = [...]int{1, 2, 3, 4, 5} \/\/ \u4e0d\u786e\u5b9a\u957f\u5ea6\r\nd := [...]int{1, 2, 3, 4, 5}\r\n<\/pre>\n\u5982\u679c\u4e0d\u77e5\u9053\u6570\u7ec4\u5143\u7d20\u7684\u8bdd\uff0c\u53ef\u4ee5\u8fd9\u6837\uff1a<\/p>\n
\r\nvar a [5]int\r\nb := [5]int{}\r\nc := make([]int, 5)\r\n<\/pre>\n\u6ce8\u610f\uff1a\u7c7b\u578b\u63a8\u65ad\uff0c\u53ef\u8981\u521d\u59cb\u5316\u7684\uff0c\u5982\u679cb := [5]int\uff0c\u5c31\u4f1a\u62a5\u9519\u7684\u3002\u800cvar a [5]int\uff0c\u5219\u4e0d\u9700\u8981\u521d\u59cb\u5316\u3002<\/p>\n
\u4e8c\u7ef4\u6570\u7ec4\u521d\u59cb\u5316<\/strong><\/span><\/div>\n\u6bd4\u59823*4\uff1a<\/p>\n
\r\nvar a [3][4]int\r\n<\/pre>\n\u7ed3\u679c\u4e3a\uff1a
\n[[0 0 0 0] [0 0 0 0] [0 0 0 0]]<\/p>\n
\u7c7b\u578b\u63a8\u65ad\uff1a<\/p>\n
\r\na := [3][4]int{}\r\n<\/pre>\n\u7ed3\u679c\u4e3a\uff1a
\n[[0 0 0 0] [0 0 0 0] [0 0 0 0]]<\/p>\n
\u6ce8\u610f\uff1a\u56fa\u5b9a\u957f\u5ea6\u7684\u65f6\u5019\uff0c\u4e0d\u80fd\u662f\u53d8\u91cf\uff0c\u6bd4\u5982\uff1a<\/p>\n
\r\nm, n := 3, 4\r\nvar a [m][n]int \/\/ \u62a5\u9519\uff0c\u5fc5\u987b\u662f\u5e38\u91cf\u8868\u8fbe\u5f0f\r\n<\/pre>\n\u5982\u679c\u4e00\u5b9a\u8981\u53d8\u91cf\u5462\uff1f\u90a3\u5c31\u5f97\u5207\u7247\u4e86\u4e86<\/p>\n
\r\nfunc main() {\r\n m, n := 3, 4\r\n a := make([][]int, m) \/\/ \u4e8c\u7ef4\u5207\u7247\uff0c3\u884c\r\n for i := range a {\r\n a[i] = make([]int, n) \/\/ \u6bcf\u4e00\u884c4\u5217\r\n }\r\n fmt.Println(a)\r\n}\r\n<\/pre>\n\u7ed3\u679c\uff1a
\n[[0 0 0 0] [0 0 0 0] [0 0 0 0]]<\/p>\n
\u6ce8\u610f\uff0c\u6709\u4e00\u79cd\u60c5\u51b5\uff0c\u5982\u679c\u6ca1\u6709\u89c4\u5b9a\u957f\u5ea6\u6216\u8005\u521d\u59cb\u5316\uff0c\u8bbf\u95ee\u5143\u7d20\u4f1arange out\u5462\uff1a<\/p>\n
\r\nvar a []int \/\/ or a := []int{}\r\nfmt.Println(a) \/\/ []\r\na[0] = 1 \/\/ \u62a5\u9519\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"\u4e4b\u524d\uff0c\u5237Leetcode\u7684\u65f6\u5019\uff0c\u6709\u4e9b\u9898\u9700\u8981\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4\uff0c\u800c\u4e00\u7ef4\u6570\u7ec4\u7684\u521d\u59cb\u5316\uff0c\u6bd4\u5982\uff1a var a = [5]i […]<\/p>\n","protected":false},"author":668,"featured_media":153204,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-217345","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/217345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=217345"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/217345\/revisions"}],"predecessor-version":[{"id":217348,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/217345\/revisions\/217348"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/153204"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=217345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=217345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=217345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}