aprendago icon indicating copy to clipboard operation
aprendago copied to clipboard

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

Open vkorbes opened this issue 5 years ago • 21 comments

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!

vkorbes avatar Sep 30 '20 17:09 vkorbes

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

diegoparra avatar Oct 07 '20 19:10 diegoparra

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

andersoncleyson avatar Oct 09 '20 21:10 andersoncleyson

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

haystem avatar Nov 20 '20 02:11 haystem

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.

an4kein avatar Feb 18 '21 14:02 an4kein

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

alansantosmg avatar Apr 21 '21 12:04 alansantosmg

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

Lucasmirandar avatar Jun 09 '21 22:06 Lucasmirandar

4. 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.
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:

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


JPauloMoura avatar Aug 09 '21 01:08 JPauloMoura

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

andersoncleyson avatar Sep 13 '21 11:09 andersoncleyson

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

tomashugo avatar Oct 10 '21 15:10 tomashugo

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 avatar Mar 15 '22 16:03 CaueFarias

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

viniciussanchez avatar Mar 17 '22 16:03 viniciussanchez

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

AlissonAp avatar Apr 15 '22 00:04 AlissonAp

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

image

wfrsilva avatar May 27 '22 02:05 wfrsilva

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

M3L1M avatar Feb 13 '23 03:02 M3L1M

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)

}

adelsonsljunior avatar May 13 '23 22:05 adelsonsljunior

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

DominMFD avatar May 15 '24 13:05 DominMFD

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

}

thiagoCalazans-dev avatar May 18 '24 11:05 thiagoCalazans-dev

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

Vitor-Zen avatar Jul 04 '24 15:07 Vitor-Zen