vkorbes / aprendago

Curso completo em português da linguagem Go, de zero a ninja! 🇧🇷
http://aprendago.com
1k stars 179 forks source link

Exercício: Capítulo 9, Exercício 4 (Nível: 4) #30

Open vkorbes opened 3 years ago

vkorbes commented 3 years ago

Exercício: Capítulo 9, Exercício 4 (Nível: 4)

Link para o vídeo:

Use esta thread para compartilhar sua solução, discutir o exercício com os colegas e pedir ajuda caso tenha dificuldades!

diegoparra commented 3 years ago

Esse exercício achei bem tranquilo de fazer, a questão dos 3 pontinhos tava bem recente na memória.

https://play.golang.org/p/1eX43A3T1jL

andersoncleyson commented 3 years ago

https://play.golang.org/p/JD_aTOaoaS8

haystem commented 3 years ago
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)
}
an4kein commented 3 years ago

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.
alansantosmg commented 3 years ago

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)
}
Lucasmirandar commented 3 years ago

https://play.golang.org/p/vKJgAO5hozj

JPauloMoura commented 2 years ago

4. Começando com a seguinte slice:

x := []int{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}

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] 

Resolução do Exercício


andersoncleyson commented 2 years ago
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)
}
tomashugo commented 2 years ago
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)
}
CaueFarias commented 2 years ago

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)

}

viniciussanchez commented 2 years ago

https://go.dev/play/p/d7t3zErpE02

AlissonAp commented 2 years ago

https://go.dev/play/p/Kw_tBtwDGix

wfrsilva commented 2 years ago

Cap. 9 – Exercícios: Nível #4 – 4 https://go.dev/play/p/ESoJGUMGEXz

image

M3L1M commented 1 year ago

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

adelsonsljunior commented 1 year ago
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)

}
DominMFD commented 2 months ago

https://go.dev/play/p/QNzoBinvuFu

thiagoCalazans-dev commented 2 months ago
// 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)

}
Vitor-Zen commented 3 weeks ago

https://go.dev/play/p/xVDdp5dVD7a