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 5, Exercício 1 (Nível: 2) #10

Open vkorbes opened 3 years ago

vkorbes commented 3 years ago

Exercício: Capítulo 5, Exercício 1 (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/7oiWZLQydBP

haystem commented 3 years ago

Inclui um a mais

package main

import("fmt")

func main(){
  x:=13878493
  fmt.Printf("O valor de %v em binário é: %b \n",x,x)
  fmt.Printf("O valor de %v em decimal é: %d \n",x,x)
  fmt.Printf("O valor de %v em octagonal é: %o \n",x,x)
  fmt.Printf("O valor de %v em hexadecimal é: %x \n",x,x)

}
guifeliper commented 3 years ago

Eu tinha esquecido o do hexadecimal de cabeça tive que dar uma recapitulada.

package main

import (
    "fmt"
)

func main() {
    x := 100
    fmt.Printf("Decimal: %d \n Binário %b \n hexadecimal %#x", x, x, x)
}
Julian-ie commented 3 years ago

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

thiagoalgo commented 3 years ago

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

viniciussanchez commented 3 years ago

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

tomxdev commented 3 years ago

package main

import "fmt"

func main() {

x := 100
fmt.Printf("DECIMAL: %d, BINARY: %b, HEXADECIMAL: %#x", x , x, x)

}

victorinno commented 3 years ago

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

ygorsimoes commented 3 years ago
package main

import (
    "fmt"
    "os"
)

func main() {
    numero := 10
    fmt.Print("Insira alguma coisa: ")

    // Entrada de dados
    numero, err := fmt.Scan(&numero)

    //Trata o possível erro da entrada de dados
    if err != nil {
        // Sai do programa com o status diferente de 0
        os.Exit(-1)
    }

    // Imprime a variável em Decimal, Binário e Hexadecimal
    fmt.Printf("\nDecimal: %d \nBinário: %b \nHexadecimal: %#x", numero, numero, numero)
}

Output:

Decimal: 10 
Binário: 1010 
Hexadecimal: 0xa
JPauloMoura commented 3 years ago

Resolução do Exercício

Lucasmirandar commented 3 years ago

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

avlambertucci commented 3 years ago

https://play.golang.org/p/OfaeTlS3-V1

isonux commented 3 years ago

package main

import ( "fmt" )

var num = 1024

func main() { // Sinceramente eu não havia lembrado do '#' no numero hexa // essa eh a v2 no meu programa fmt.Printf("%d\n%b\n%#x", num, num, num) }

andersoncleyson commented 2 years ago
package main

import (
    "fmt"

)

func main(){

    fmt.Println("Decimal\tBinário\tHexa\tCaractere")
    for i := 33; i <= 126; i++{
        fmt.Printf("  %d \t%b\t%#x\t    %c\n", i, i, i, i)
    }

}
guilherme-de-marchi commented 2 years ago
package main

import "fmt"

func main() {

    var value int
    fmt.Print("Valor: ")
    fmt.Scan(&value)

    fmt.Printf("\nDecimal:     %d\n", value)
    fmt.Printf("Hexadecimal: %x\n", value)
    fmt.Printf("Binário:     %b\n", value)
    fmt.Printf("Octagonal:   %o\n", value)

}

Output:

Valor: 10

Decimal:     10
Hexadecimal: 0xa
Binário:     0b1010
Octagonal:   012
ltbatis commented 2 years ago

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

CarlosSMA commented 2 years ago
package main

import (
    "fmt"
)

func main() {
    a := 404
    fmt.Printf("Binário - %b \nDecimal - %d \nHexadecimal - %#x\n", a, a, a)
}

Output

Binário - 110010100 
Decimal - 404 
Hexadecimal - 0x194
AlissonAp commented 2 years ago

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

gustavomfc commented 2 years ago

package main

import "fmt"

func main() { n := 42

fmt.Printf("%v em Decimal = %d\n", n, n)
fmt.Printf("%v em Binário = %b\n", n, n)
fmt.Printf("%v em Hexa = %x\n", n, n)

}

M3L1M commented 1 year ago

a:=100 fmt.Printf("%d\t%#x\t%b", a, a, a)

adelsonsljunior commented 1 year ago
package main

import (
    "fmt"
)

func main() {

    a := 13

    fmt.Printf("Decimal: %d", a)
    fmt.Printf("\nBinároo: %b", a)
    fmt.Printf("\nDecimal: %#x", a)
}
an4kein commented 1 year ago
https://go.dev/play/p/XbCuFR5ZMHu

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

// https://go.dev/play/p/MslHxAYgayM
import "fmt"

func main() {
    x := 100
    fmt.Printf("%d\n%#b\n%#x", x, x, x)
}

/*
- Escreva um programa que mostre um número em decimal, binário, e hexadecimal.
*/
---------------------------------------------------------------------------------------------------------------------------------------------
100
0b1100100
0x64
Program exited.
---------------------------------------------------------------------------------------------------------------------------------------------
Gabrielfrahm commented 5 months ago

package main

import "fmt"

var n = 10

func main() {
    fmt.Printf("%d, %#b, %#x", n, n, n)
}
mrercj commented 3 months ago

https://goplay.tools/snippet/ygKZ_bmccX7

image
1r4mos commented 3 months ago

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

DominMFD commented 2 months ago

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

Vitor-Zen commented 1 month ago

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