Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "bufio"
- "os"
- "strconv"
- )
- func main() {
- var easterBreadCount, points, topPoints int
- fmt.Scanln(&easterBreadCount)
- var baker, command, topBaker string
- scanner := bufio.NewScanner(os.Stdin)
- for i := 0; i < easterBreadCount; i++ {
- bakerPoints := 0
- scanner.Scan()
- baker = scanner.Text()
- scanner.Scan()
- command = scanner.Text()
- for command != "Stop" {
- points, _ = strconv.Atoi(command)
- bakerPoints += points
- scanner.Scan()
- command = scanner.Text()
- }
- if topPoints < bakerPoints {
- topBaker = baker
- topPoints = bakerPoints
- fmt.Printf("%s has %d points.\n%s is the new number 1!\n", topBaker, topPoints, topBaker)
- } else {
- fmt.Printf("%s has %d points.\n", baker, bakerPoints)
- }
- }
- fmt.Printf("%s won competition with %d points!\n", topBaker, topPoints)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement