Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a55499bf40 | |||
| 30995e55d3 |
+47
@@ -0,0 +1,47 @@
|
|||||||
|
# Binários compilados
|
||||||
|
*.exe
|
||||||
|
*.exe~
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Binário de teste, criado por 'go test -c'
|
||||||
|
*.test
|
||||||
|
|
||||||
|
# Output de profiling do go tool cover
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Dependências (se usar vendor)
|
||||||
|
/vendor/
|
||||||
|
|
||||||
|
# Arquivo de workspace do Go (a menos que queira versionar)
|
||||||
|
go.work
|
||||||
|
go.work.sum
|
||||||
|
|
||||||
|
# Variáveis de ambiente / segredos
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
*.env
|
||||||
|
|
||||||
|
# Build outputs comuns (ajuste conforme seu projeto)
|
||||||
|
/bin/
|
||||||
|
/build/
|
||||||
|
/dist/
|
||||||
|
|
||||||
|
# Arquivos de IDE / editor
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# Arquivos específicos do sistema operacional
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Arquivos de configuração local
|
||||||
|
config.local.yaml
|
||||||
|
config.local.json
|
||||||
@@ -9,14 +9,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
numero, tentativas := 7, 3
|
const TENTATIVAS = 3
|
||||||
|
numero := 7
|
||||||
scanner := bufio.NewScanner(os.Stdin)
|
scanner := bufio.NewScanner(os.Stdin)
|
||||||
|
|
||||||
fmt.Println("Bem-vindo ao jogo de adivinhação!")
|
fmt.Println("Bem-vindo ao jogo de adivinhação!")
|
||||||
fmt.Printf("Você tem %d tentativas para adivinhar o número entre 1 e 10.\n", tentativas)
|
fmt.Printf("Você tem %d tentativas para adivinhar o número entre 1 e 10.\n", TENTATIVAS)
|
||||||
|
|
||||||
for i := 0; i <= tentativas; i++ {
|
tentativa := 0
|
||||||
if i == tentativas {
|
|
||||||
|
for tentativa < TENTATIVAS {
|
||||||
|
if tentativa == TENTATIVAS {
|
||||||
fmt.Println("Suas tentativas acabaram. O número correto era:", numero)
|
fmt.Println("Suas tentativas acabaram. O número correto era:", numero)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -27,26 +30,18 @@ func main() {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Deve ser informado um número.")
|
fmt.Println("Deve ser informado um número.")
|
||||||
continue
|
continue // colocado para pular a proxima iteração e não contar a tentativa
|
||||||
}
|
|
||||||
// talvez não necessite checar se o número é menor que um
|
|
||||||
//
|
|
||||||
if chuteInt < 1 {
|
|
||||||
fmt.Println("O número deve ser maior que 0.")
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if chuteInt < numero {
|
switch {
|
||||||
fmt.Println("O número é maior")
|
case chuteInt < numero:
|
||||||
}
|
fmt.Println("O número é maior, tente novamente.")
|
||||||
|
case chuteInt > numero:
|
||||||
if chuteInt > numero {
|
fmt.Println("O número é menor, tente novamente.")
|
||||||
fmt.Println("O número é menor")
|
default:
|
||||||
}
|
|
||||||
|
|
||||||
if chuteInt == numero {
|
|
||||||
fmt.Println("Parabéns! Você acertou o número!")
|
fmt.Println("Parabéns! Você acertou o número!")
|
||||||
break
|
}
|
||||||
}
|
|
||||||
|
tentativa++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user