vkorbes / aprendago

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

Exercício: Capítulo 5, Exercício 6 (Nível: 2) #15

Open vkorbes opened 3 years ago

vkorbes commented 3 years ago

Exercício: Capítulo 5, Exercício 6 (Nível: 2)

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

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

andersoncleyson commented 3 years ago

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

basquegran2 commented 3 years ago

https://play.golang.org/p/5JcMnLv50MF

haystem commented 3 years ago

Esse foi mais fácil, já q errei iota antes não considerando constante. Tentei var mas deu erro

package main 

import ("fmt")

const (_ = iota
        x = iota + 2020
        y
        t
        b
        )

func main(){
   fmt.Println(x,y,t,b)
}
guifeliper commented 3 years ago

Massa esse iota.

package main

import (
    "fmt"
)

const (
    _ = iota + 2020
    a
    b
    c
    d
)

func main() {
    fmt.Printf("Ano %d\nAno %d\nAno %d\nAno %d\n", a, b, c, d)
}
Julian-ie commented 3 years ago

https://play.golang.org/p/BYwP0r2d3q-

thiagoalgo commented 3 years ago

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

viniciussanchez commented 3 years ago

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

tomxdev commented 3 years ago
package main

import "fmt"

const (
        _ = 1994 + iota
        b
        c
        d
        e
    )
func main() {
    fmt.Println( b, c, d, e)
}
an4kein commented 3 years ago

https://play.golang.org/p/JU-jP7bkXvk

victorinno commented 3 years ago

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

ygorsimoes commented 3 years ago
package main

import "fmt"

// Declara e atribui constantes cujos valores sejam os próximos 4 anos utilizando iota
const (
    _ = 2021 + iota
    primeiroAno
    segundoAno
    terceiroAno
    quartoAno
)

func main() {

    // Imprime as constantes
    fmt.Println(primeiroAno, segundoAno, terceiroAno, quartoAno)
}

Output:

2022 2023 2024 2025
JPauloMoura commented 3 years ago
package main

//Utilizando iota, crie 4 constantes cujos valores sejam os próximos 4 anos demonstre estes valores.
import "fmt"

const (
    _ = iota + 2021
    ano2
    ano3
    ano4
    ano5
)

func main() {
    fmt.Print(ano2, ano3, ano4, ano5)
}

Resolução do Exercício

Lucasmirandar commented 3 years ago

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

andersoncleyson commented 2 years ago
package main

import "fmt"

const (
    a = iota + 2021
    b
    c
    d 
)

func main(){
    fmt.Println(a, b, c, d)
}
ltbatis commented 2 years ago

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

CarlosSMA commented 2 years ago
package main

import (
    "fmt"
)

const (
    _ = iota + 2021
    a
    b
    c
    d
)

func main() {
    fmt.Println(a, b, c, d)
}

Output

2022 2023 2024 2025
AlissonAp commented 2 years ago

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

CaueFarias commented 2 years ago

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

gustavomfc commented 2 years ago
package main

import "fmt"

func main() {
    const (
        _ = iota + 2022
        a
        b
        c
        d
    )

    fmt.Printf("%v\n%v\n%v\n%v\n", a, b, c, d)

}
M3L1M commented 1 year ago

const ( _ = 2023 + iota a b c d )

func main() { fmt.Println(a, b, c, d) }

an4kein commented 1 year ago
https://go.dev/play/p/N86MdKOYKxO

// You can edit this code!
// Click here and start typing.
package main

import "fmt"

type teste int

func main() {

    const (
        a = 2023 + iota
        b
        c
        d
    )

    fmt.Println(a, b, c, d)
}

/*
- Utilizando iota, crie 4 constantes cujos valores sejam os próximos 4 anos.
- Demonstre estes valores.
*/

---------------------------------------------------------------------------------------------------------------------------------------------
2023 2024 2025 2026

Program exited.
---------------------------------------------------------------------------------------------------------------------------------------------
1r4mos commented 2 months ago

https://go.dev/play/p/9euEMjsRHym

DominMFD commented 1 month ago

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

Vitor-Zen commented 1 week ago

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