Advertisement
Spocoman

PC Game Shop

Oct 12th, 2024
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.93 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "bufio"
  6.   "os"
  7.   "strconv"
  8. )
  9.  
  10. func main() {
  11.     var hearthstones, fornites, overwatchs, others int
  12.    
  13.     scanner := bufio.NewScanner(os.Stdin)
  14.     scanner.Scan()
  15.     games,_ := strconv.Atoi(scanner.Text())
  16.  
  17.     var game string
  18.  
  19.     for i := 0; i < games; i++ {
  20.         scanner.Scan()
  21.         game = scanner.Text()
  22.         switch game {
  23.         case "Hearthstone":
  24.             hearthstones++
  25.         case "Fornite":
  26.             fornites++
  27.         case "Overwatch":
  28.             overwatchs++
  29.         default:
  30.             others++
  31.         }
  32.     }
  33.  
  34.     fmt.Printf("Hearthstone - %.2f%%\n", float64(hearthstones) / float64(games) * 100)
  35.     fmt.Printf("Fornite - %.2f%%\n", float64(fornites) / float64(games) * 100)
  36.     fmt.Printf("Overwatch - %.2f%%\n", float64(overwatchs) / float64(games) * 100)
  37.     fmt.Printf("Others - %.2f%%\n", float64(others) / float64(games) * 100)
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement