vkorbes / aprendago

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

Exercício: Capítulo 7, Exercício 1 (Nível: 3) #17

Open vkorbes opened 4 years ago

vkorbes commented 4 years ago

Exercício: Capítulo 7, Exercício 1 (Nível: 3)

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 4 years ago

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

haystem commented 3 years ago

Esse foi bem simples, poderiamos fazer com if?

package main 

import ("fmt")

func main (){

  for x:=0; x<=10000; x++{
    fmt.Printf("%d \n",x)
  }
}
capelaum commented 3 years ago
package main

import "fmt"

// todos numero de 1 a 10000

func main() {
    n := 1
    for {
        if n > 10000     { break }
    fmt.Println("Numero:", n)
    n++
    }
}
thiagoalgo commented 3 years ago

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

viniciussanchez commented 3 years ago

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

tomxdev commented 3 years ago
package main

import "fmt"

func main() {

    for i := 1; i <=10000; i++{
        fmt.Println(i)
    }
}
an4kein commented 3 years ago

// Põe na tela: todos os números de 1 a 10000.

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

ygorsimoes commented 3 years ago
package main

import "fmt"

func main() {

    // Loop de 1 a 10000
    for i := 1; i <= 10000; i++ {
        // Imprime o Loop
        fmt.Println(i)
    }
}

Output:

1
2
3
...
9997
9998
9999
10000
alansantosmg commented 3 years ago

De uma maneira um pouco diferente, colocando 20 números por linha, e alinhando os números à direita pra ficar bonitinho:


package main

import "fmt"

func main() {
    numbersPerLine := 0

    for i := 1; i <= 1000; i++ {

        // align and show numbers 5 positions from right
        fmt.Printf("%5v", i)

        numbersPerLine++
        if numbersPerLine == 20 {
            fmt.Println()
            numbersPerLine = 0
        }
    }
}
JPauloMoura commented 3 years ago
package main

// Exiba todos os números de 1-10000
import "fmt"

func main() {
    for n := 1; n <= 10000; n++ {
        fmt.Print(n, " ")
    }
}

Resolução do Exercício

Lucasmirandar commented 3 years ago

// Põe na tela: todos os números de 1 a 10000. package main

import "fmt"

func main() { for x := 1; x <= 10000; x++{ fmt.Println(x) } }

andersoncleyson commented 3 years ago
package main

import "fmt"

func main(){
    for i := 1; i < 10000+1; i++{
        fmt.Println(i)
    }
}
CarlosSMA commented 2 years ago
package main

import (
    "fmt"
)

func main() {
    for i := 0 ; i <= 10000 ; i++ {
        fmt.Println(i)
    }
}
CaueFarias commented 2 years ago

https://go.dev/play/p/HQp4cJPMwQ-

viniciusbmello commented 2 years ago
package main

import "fmt"

var x int

func main() {
    x = 1
    for {
        if x < 10001 {
            fmt.Println(x)
            x++
        } else {
            break
        }
    }
}
wfrsilva commented 2 years ago

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

lneute commented 2 years ago

Minha solução

Playground

package main

import (
    "fmt"
)

func main() {

    LIMIT := 10000
    counter_limit := 10
    counter := 0
    row := 1
    printed := false

    ascii_start := 65
    fmt.Printf("\t ")
    for col := ascii_start; col < ascii_start+counter_limit; col++ {
        fmt.Printf("%v\t", string(col))
    }
    fmt.Println("")
    for x := 1; x < LIMIT+1; x++ {

        if !printed {
            fmt.Printf("%v.\t ", row)
        }
        fmt.Printf("%v\t", x)
        printed = true

        counter++

        if counter == counter_limit {
            fmt.Println("\n-----")
            counter = 0
            row++
            printed = false
        }

    }

    fmt.Println("Fim!")
}
M3L1M commented 1 year ago

func main() { for i := 1; i <= 10000; i++ { fmt.Println(i) } }

adelsonsljunior commented 1 year ago
package main

import "fmt"

func main() {
    for i := 1; i <= 10000; i++ {
        fmt.Println(i)
    }
}
an4kein commented 1 year ago

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

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

import "fmt"

func main() {

    for i := 0; i <= 1000; i++ {
        fmt.Println(i)
    }
}
hiercj commented 5 months ago

package main

import "fmt"

func main() { for n := 1; n <= 10000; n++ { fmt.Println(n) } }

DominMFD commented 4 months ago

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

Vitor-Zen commented 3 months ago

https://go.dev/play/p/ToUB8Vxh1-l