Advertisement
Mushi

ifinit.go

Apr 25th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.36 KB | None | 0 0
  1. // controles ifinit ifinit.go
  2. package main
  3.  
  4. import (
  5.     "fmt"
  6.     "math/rand"
  7.     "time"
  8. )
  9.  
  10. func numeroAleatorio() int {
  11.     s := rand.NewSource(time.Now().UnixNano())
  12.     r := rand.New(s)
  13.     return r.Intn(10)
  14.  
  15. }
  16.  
  17. func main() {
  18.     if i := numeroAleatorio(); i > 5 { // tb suportado no switch
  19.         fmt.Println("Ganhou!!!")
  20.     } else {
  21.         fmt.Println("Perdeu!")
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement