Giter Club home page Giter Club logo

Comments (16)

diegoparra avatar diegoparra commented on August 22, 2024

https://play.golang.org/p/Xmuf4-dSlDE

from aprendago.

andersoncleyson avatar andersoncleyson commented on August 22, 2024

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

from aprendago.

haystem avatar haystem commented on August 22, 2024

fiz com strings e printf

package main

import("fmt")

func main(){
 array := [10]string{"Ana","Joana","Siraya","Carla","Vivian","Betina","Laritssa","Bianca","Muana","Juressica"} 

  for indice, valor:= range array{
    fmt.Printf("%d, %s \n", indice, valor)
  }
  fmt.Printf("%T",array)
}

from aprendago.

an4kein avatar an4kein commented on August 22, 2024

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

package main

import (
	"fmt"
)

func main() {
	fmt.Println(`Usando uma literal composta:`)
	fmt.Println("")
	slice := []int{}
	fmt.Printf("- Crie uma slice de tipo int:")
	fmt.Println("")
	fmt.Printf("%T", slice)
	fmt.Println("")
	fmt.Println("")

	fmt.Printf("- Atribua 10 valores a ela: \n")
	slice = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	fmt.Println(slice)
	fmt.Println("")

	fmt.Printf("- Utilize range para demonstrar todos estes valores.\n")
	for v := range slice {
		fmt.Println(slice[v])
	}
	fmt.Println("")
	fmt.Printf("- E utilize format printing para demonstrar seu tipo.\n")
	fmt.Printf("Type of slice: %T", slice)
}

Output

Usando uma literal composta:

- Crie uma slice de tipo int:
[]int

- Atribua 10 valores a ela: 
[1 2 3 4 5 6 7 8 9 10]

- Utilize range para demonstrar todos estes valores.
1
2
3
4
5
6
7
8
9
10

- E utilize format printing para demonstrar seu tipo.
Type of slice: []int
Program exited.

from aprendago.

alansantosmg avatar alansantosmg commented on August 22, 2024
package main

import "fmt"

func main() {

	umaSlice := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

	for _, v := range umaSlice {
		fmt.Printf("%v ", v)
	}

	fmt.Printf("%T", umaSlice)
}

from aprendago.

Lucasmirandar avatar Lucasmirandar commented on August 22, 2024

https://play.golang.org/p/oW-soISfjuE

from aprendago.

JPauloMoura avatar JPauloMoura commented on August 22, 2024

2. Crie uma Slice do tipo int, atribua 10 valores a ela, utilize range para demonstrar todos estes valores, e utilize format printing para demonstrar seu tipo.

package main

import "fmt"

func main() {
	slice := []int{0, 10, 20, 30, 40, 50, 70, 80, 90, 100}
	for i, v := range slice {
		fmt.Printf("Indíce  %d: %d\n", i, v)
	}
	fmt.Printf("Tipo do slice: %T", slice)
}

Resultado:

Indíce  0: 0
Indíce  1: 10
Indíce  2: 20
Indíce  3: 30
Indíce  4: 40
Indíce  5: 50
Indíce  6: 70
Indíce  7: 80
Indíce  8: 90
Indíce  9: 100
Tipo do slice: []int  

Resolução do Exercício


from aprendago.

tomashugo avatar tomashugo commented on August 22, 2024
package main

import (
	"fmt"
)

func main() {
	slice := [10]int{1,2,3,4,5,6,7,8,9,10}
	
	for key, value := range slice {
		fmt.Printf("Índice: %v, Valor: %v\n",key, value)
	}
	
	fmt.Printf("%T\n",slice)
}

from aprendago.

CaueFarias avatar CaueFarias commented on August 22, 2024

`package main

import (
"fmt"
)

func main() {

slice := []int{10, 20, 30, 40, 50, 60, 70, 80, 90, 100}

for índice, número := range slice {
	fmt.Println("No índice: ", índice, "Temos o valor: ", número)
}
fmt.Printf("%T", slice)

}
`

from aprendago.

viniciussanchez avatar viniciussanchez commented on August 22, 2024

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

from aprendago.

AlissonAp avatar AlissonAp commented on August 22, 2024

https://go.dev/play/p/oa3YJ50-7_7

from aprendago.

wfrsilva avatar wfrsilva commented on August 22, 2024

Cap. 9 – Exercícios: Nível #4 – 2
https://go.dev/play/p/DWOFNp-oj1N
image

from aprendago.

M3L1M avatar M3L1M commented on August 22, 2024

func main() {
slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

for indice, valor := range slice {
	fmt.Printf("%v - %v\n", indice, valor)
}

fmt.Printf("%T", slice)

}

from aprendago.

adelsonsljunior avatar adelsonsljunior commented on August 22, 2024
package main

import (
	"fmt"
)

func main() {

	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	for indice, valor := range slice {
		fmt.Println(indice, valor)
	}
	fmt.Printf("%T", slice)
}

from aprendago.

DominMFD avatar DominMFD commented on August 22, 2024

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

from aprendago.

thiagoCalazans-dev avatar thiagoCalazans-dev commented on August 22, 2024

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

from aprendago.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.