Advertisement
Spocoman

Football Tournament

Oct 9th, 2024
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.89 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "bufio"
  5.     "fmt"
  6.     "os"
  7.     "strconv"
  8. )
  9.  
  10. func main() {
  11.     scanner := bufio.NewScanner(os.Stdin)
  12.     scanner.Scan()
  13.     team := scanner.Text()
  14.  
  15.     scanner.Scan()
  16.     matchCount,_ := strconv.Atoi(scanner.Text())
  17.    
  18.     var won, drawn, lost int
  19.  
  20.     for i := 0; i < matchCount; i++ {
  21.         scanner.Scan()
  22.         result := scanner.Text()
  23.         if result == "W" {
  24.             won++
  25.         } else if result == "D" {
  26.             drawn++
  27.         } else {
  28.             lost++
  29.         }
  30.     }
  31.  
  32.     if matchCount == 0 {
  33.         fmt.Printf("%s hasn't played any games during this season.\n", team)
  34.     } else {
  35.         fmt.Printf("%s has won %d points during this season.\nTotal stats:\n## W: %d\n## D: %d\n## L: %d\nWin rate: %.2f%%\n",
  36.                     team, won * 3 + drawn, won, drawn, lost, float64(won) / float64(matchCount) * 100)
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement