Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var r, s, c, maxJuice, raspberries, strawberries, cherries int
- fmt.Scanln(&r)
- fmt.Scanln(&s)
- fmt.Scanln(&c)
- fmt.Scanln(&maxJuice)
- juice := 0.0
- for j := 0; j <= r; j++ {
- for k := 0; k <= s; k++ {
- for l := 0; l <= c; l++ {
- currentJuice := 4.5 * float64(j) + 7.5 * float64(k) + 15 * float64(l)
- if juice < currentJuice && currentJuice <= float64(maxJuice) {
- juice = currentJuice
- raspberries = j
- strawberries = k
- cherries = l
- }
- }
- }
- }
- fmt.Printf("%d Raspberries, %d Strawberries, %d Cherries. Juice: %d ml.", raspberries, strawberries, cherries, int(juice))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement