Advertisement
Spocoman

Tournament of Christmas

Oct 14th, 2024
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.99 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var days, winTotal, loseTotal int
  7.     fmt.Scanln(&days)
  8.  
  9.     totalSum := 0.0
  10.    
  11.     var command string
  12.  
  13.     for i := 0; i < days; i++ {
  14.         var win, lose int
  15.         sum := 0.0
  16.  
  17.         for {
  18.             fmt.Scanln(&command)
  19.             if command == "win" {
  20.                 sum += 20
  21.                 win++
  22.             } else if command == "lose" {
  23.                 lose++
  24.             } else if command == "Finish" {
  25.                 if win > lose {
  26.                     totalSum += sum * 1.1
  27.                     winTotal += win
  28.                 } else {
  29.                     totalSum += sum
  30.                     loseTotal += lose
  31.                 }
  32.                 break
  33.             }
  34.         }
  35.     }
  36.  
  37.     if winTotal > loseTotal {
  38.         fmt.Printf("You won the tournament! Total raised money: %.2f\n", totalSum * 1.2)
  39.     } else {
  40.         fmt.Printf("You lost the tournament! Total raised money: %.2f\n", totalSum)
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement