Open vkorbes opened 3 years ago
Esse exercício achei bem tranquilo de fazer, a questão dos 3 pontinhos tava bem recente na memória.
package main
import("fmt")
func main(){
x := []int{42,43,44,45,46,47,48,49,50,51}
y := []int{56,57,58,59,60}
x = append(x,52)
fmt.Println(x)
x = append(x,53,54,55)
fmt.Println(x)
x = append(x,y...)
fmt.Println(x)
}
https://play.golang.org/p/ufaDWyYffEB
Nao esqueca de colocar os tres pontinhos kkkkk
package main
import (
"fmt"
)
func main() {
x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
fmt.Println(x)
x = append(x, 52)
fmt.Println(x)
x = append(x, 53, 54, 55)
fmt.Println(x)
y := []int{56, 57, 58, 59, 60}
x = append(x, y...)
fmt.Println(x)
}
Output
[42 43 44 45 46 47 48 49 50 51]
[42 43 44 45 46 47 48 49 50 51 52]
[42 43 44 45 46 47 48 49 50 51 52 53 54 55]
[42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60]
Program exited.
My solution:
package main
import "fmt"
fpackage main
import "fmt"
func main() {
x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
x = append(x, 52)
x = append(x, 53, 54, 55)
y := []int{56, 57, 58, 59, 60}
x = append(x, y...)
fmt.Println(x)
}
x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
package main
import "fmt"
func main() { x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
x = append(x, 52)
x = append(x, 53, 54, 55)
fmt.Printf("slice: %v\n", x)
y := []int{56, 57, 58, 59, 60}
x = append(x, y...)
fmt.Printf("slice: %v\n", x)
}
#### Resultado:
```bash
slice: [42 43 44 45 46 47 48 49 50 51 52 53 54 55]
slice: [42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60]
package main
import "fmt"
func main() {
x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
x = append(x, 52)
fmt.Println(x)
x = append(x, 53, 54, 55)
fmt.Println(x)
y := []int{56, 57, 58, 59, 60}
x = append(x, y...)
fmt.Println(x)
}
package main
import (
"fmt"
)
func main() {
x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
x = append(x, 52)
x = append(x, 53, 54, 55)
fmt.Println(x)
y := []int{56, 57, 58, 59, 60}
x = append(x, y...)
fmt.Println(x)
}
package main
import ( "fmt" )
func main() {
x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
x = append(x, 52)
x = append(x, 53, 54, 55)
fmt.Println(x)
y := []int{56, 57, 58, 59, 60}
x = append(x, y...)
fmt.Println(x)
}
Cap. 9 – Exercícios: Nível #4 – 4 https://go.dev/play/p/ESoJGUMGEXz
func main() { x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51} fmt.Println(x) x = append(x, 52) fmt.Println(x) x = append(x, 53, 54, 55) fmt.Println(x) y := []int{56, 57, 58, 59, 60} x = append(x, y...) fmt.Println(x) }
package main
import (
"fmt"
)
func main() {
x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
x = append(x, 52)
x = append(x, 53, 54, 55)
fmt.Println(x)
y := []int{56, 57, 58, 59, 60}
x = append(x, y...)
fmt.Println(x)
}
// Click here and start typing.
package main
import "fmt"
//- Começando com a seguinte slice:
// - x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
//- Anexe a ela o valor 52;
//- Anexe a ela os valores 53, 54 e 55 utilizando uma única declaração;
//- Demonstre a slice;
//- Anexe a ela a seguinte slice:
// - y := []int{56, 57, 58, 59, 60}
//- Demonstre a slice x.
func main() {
x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}
y := []int{56, 57, 58, 59, 60}
slice1 := append(x, 52)
slice2 := append(slice1, 53, 54, 55)
slice3 := append(slice2, y...)
fmt.Println(slice1)
fmt.Println(slice2)
fmt.Println(slice3)
}
Exercício: Capítulo 9, Exercício 4 (Nível: 4)
Use esta thread para compartilhar sua solução, discutir o exercício com os colegas e pedir ajuda caso tenha dificuldades!