Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6. times := []string{"Corinthians", "Londrina", "Operário", "Leicester"}
  7. calendario := [][]string{}
  8.  
  9. lenTimes := len(times)
  10. lenTimes2 := lenTimes / 2
  11.  
  12. for y := 1; y < lenTimes; y++ {
  13. for i, x := 0, lenTimes2; i < lenTimes2; i, x = i+1, x+1 {
  14. calendario = append(calendario, []string{times[i], times[x]})
  15. }
  16. t := y + 1
  17. if t == lenTimes {
  18. t = 0
  19. }
  20. times[y], times[t] = times[t], times[y]
  21. }
  22.  
  23. for _, rodada := range calendario {
  24. fmt.Printf("%s x %s\n", rodada[0], rodada[1])
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement