-
Notifications
You must be signed in to change notification settings - Fork 0
/
array.go
59 lines (39 loc) · 928 Bytes
/
array.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import "fmt"
func main (){
// define arrays
// var arr [4]string // ' '
// // fmt.Println("arr",arr)
// // var a [3]int
// // fmt.Println("int arr", a)
// arr[0] = "Ahmed"
// arr[2] = "sara"
// arr[3] = "adam"
// // fmt.Println("arr",arr)
// arr = [4]string{"jan", "jack", "hady", "sara"}
// fmt.Println("re assigen arr", arr)
// var num = [...]int{1, 2, 3, 4, 5}
// fmt.Println("num", num)
// names := [2]string{"string"}
// fmt.Println(names)
// // len()
// arrLen := len(arr)
// fmt.Println(arrLen)
// -- 2D Arrays
XoBoard := [3][3] string{}
//fmt.Println(XoBoard)
XoBoard = [3][3] string {
[3]string{ "-", "-", "x" },
[3]string{ "-", "o", "-" },
[3]string{ "x", "o", "-" },
}
//fmt.Println(XoBoard)
fmt.Println(XoBoard[0])
fmt.Println(XoBoard[1])
fmt.Println(XoBoard[2])
//
XoBoard[0][1] = "x"
fmt.Println(XoBoard[0])
fmt.Println(XoBoard[1])
fmt.Println(XoBoard[2])
}