Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace JuiceDiet
- {
- class Program
- {
- static void Main(string[] args)
- {
- int r = int.Parse(Console.ReadLine());
- int s = int.Parse(Console.ReadLine());
- int c = int.Parse(Console.ReadLine());
- int maxJuice = int.Parse(Console.ReadLine());
- double juice = 0;
- int raspberries = 0, strawberries = 0, cherries = 0;
- for (int j = 0; j <= r; j++)
- {
- for (int k = 0; k <= s; k++)
- {
- for (int l = 0; l <= c; l++)
- {
- double currentJuice = 4.5 * j + 7.5 * k + 15 * l;
- if(juice < currentJuice && currentJuice <= maxJuice)
- {
- juice = currentJuice;
- raspberries = j;
- strawberries = k;
- cherries = l;
- }
- }
- }
- }
- Console.WriteLine($"{raspberries} Raspberries, {strawberries} Strawberries, {cherries} Cherries. Juice: {juice} ml.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement