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->

9th Nov 2022, 12:57 PM
Fahad Khan
Fahad Khan - avatar
3 Réponses
+ 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
9th Nov 2022, 2:30 PM
SoloProg
SoloProg - avatar
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?
10th Nov 2022, 10:37 AM
Fahad Khan
Fahad Khan - avatar
0
//cities := make([]string, N) // Or var cities []string cities = make([]string, N)
11th Nov 2022, 9:48 AM
SoloProg
SoloProg - avatar