+ 3

How do I do 33.2 practice in GoLang?

I've got most of the concepts down in GoLang pretty down pat, but how do I append the MULTIPLE inputs to the array? I'm very confused about it it probably sounds like a dumb question.

18th Jan 2022, 10:04 PM
Brian Dean Ullery
Brian Dean Ullery - avatar
7 Respostas
+ 2
You have to define a slice with length 0. And in the loop, this slice will be added to previous slice. It's a little bit tricky 😉 func main() { var n int fmt.Scanln(&n) //your code goes here var input int a := make([]int, 0) for i:=0; i<n; i++ { fmt.Scanln(&input) a = append(a, input) } fmt.Println(a) }
18th Jan 2022, 10:57 PM
Coding Cat
Coding Cat - avatar
+ 1
thank you
18th Jan 2022, 10:58 PM
Brian Dean Ullery
Brian Dean Ullery - avatar
0
33.2 not 32.2
18th Jan 2022, 10:36 PM
Brian Dean Ullery
Brian Dean Ullery - avatar
0
Sorry Sir
18th Jan 2022, 10:37 PM
Coding Cat
Coding Cat - avatar
0
You're good
18th Jan 2022, 10:38 PM
Brian Dean Ullery
Brian Dean Ullery - avatar
0
Brian Dean Ullery you are welcome
18th Jan 2022, 10:59 PM
Coding Cat
Coding Cat - avatar
- 1
You do not have to append anything to the array. The array is already given. menu := [6]string{"Water", "Burger", "Cake", "Soup", "Soda", "Fries"} You need to take a number as input, which indicates the choice index, and OUTPUT the corresponding item from the menu.
18th Jan 2022, 10:35 PM
Coding Cat
Coding Cat - avatar