Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var quantity, red, orange, blue, green, maxCount int
- fmt.Scanln(&quantity)
- var color, maxColor string
- for i := 0; i < quantity; i++ {
- fmt.Scanln(&color)
- switch color {
- case "red":
- red++
- case "orange":
- orange++
- case "blue":
- blue++
- case "green":
- green++
- }
- }
- if red > orange && red > blue && red > green {
- maxCount = red
- maxColor = "red"
- } else if orange > blue && orange > green && orange > red {
- maxCount = orange
- maxColor = "orange"
- } else if blue > green && blue > red && blue > orange {
- maxCount = blue
- maxColor = "blue"
- } else {
- maxCount = green
- maxColor = "green"
- }
- fmt.Printf("Red eggs: %d\nOrange eggs: %d\nBlue eggs: %d\nGreen eggs: %d\nMax eggs: %d -> %s",
- red, orange, blue, green, maxCount, maxColor)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement