0
How do i solve this problem in go?
You are making a program for a navigation system. Your program needs to take a number N as input, followed by N strings, which represent city names. Store the city names in a slice. Declare a variadic function route(), which takes its arguments from the slice. The route() function should output the route, which combines the city names using an arrow. Check the sample input/output for reference: Sample Input: 3 Boston Chicago Washington Sample Output: Boston->Chicago->Washington->
3 Respostas
+ 2
// Fahad Khan , Hope this helps
func route(arr []string) {
for i:=0; i<len(arr) ; i++ {
fmt.Printf("%s->", arr[i])
}
}
https://www.sololearn.com/compiler-playground/cuN5h1so5TST
0
package main
import "fmt"
//create the route() function
func main() {
var n int
fmt.Scanln(&n)
var cities []string
//take n strings as input and append them to the slice
//
route(cities...)
}
//Can you solve this code please?
0
//cities := make([]string, N)
// Or
var cities []string
cities = make([]string, N)