+ 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.
7 Antworten
+ 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)
}
+ 1
thank you
0
33.2 not 32.2
0
Sorry Sir
0
You're good
0
Brian Dean Ullery you are welcome
- 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.