Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "bufio"
- "os"
- "strconv"
- )
- func main() {
- var hearthstones, fornites, overwatchs, others int
- scanner := bufio.NewScanner(os.Stdin)
- scanner.Scan()
- games,_ := strconv.Atoi(scanner.Text())
- var game string
- for i := 0; i < games; i++ {
- scanner.Scan()
- game = scanner.Text()
- switch game {
- case "Hearthstone":
- hearthstones++
- case "Fornite":
- fornites++
- case "Overwatch":
- overwatchs++
- default:
- others++
- }
- }
- fmt.Printf("Hearthstone - %.2f%%\n", float64(hearthstones) / float64(games) * 100)
- fmt.Printf("Fornite - %.2f%%\n", float64(fornites) / float64(games) * 100)
- fmt.Printf("Overwatch - %.2f%%\n", float64(overwatchs) / float64(games) * 100)
- fmt.Printf("Others - %.2f%%\n", float64(others) / float64(games) * 100)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement