Advertisement
TeMePyT

Untitled

Feb 11th, 2018
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Juice_Diet
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int rasp = int.Parse(Console.ReadLine());
  14. int straw = int.Parse(Console.ReadLine());
  15. int cherry = int.Parse(Console.ReadLine());
  16. int juice = int.Parse(Console.ReadLine());
  17. int cherryUsed = 0;
  18. int strawUsed = 0;
  19. int raspUsed = 0;
  20. double juiceTotal = 0.0;
  21.  
  22.  
  23. for (int i = 0; i <= cherry; i++)
  24. {
  25. for (int j = 0; j <= straw; j++)
  26. {
  27. for (int k = 0; k <= rasp; k++)
  28. {
  29.  
  30. double juiceCurrent = i * 15 + j * 7.5 + k * 4.5;
  31. if (juiceCurrent <= juice)
  32. {
  33. if (juiceCurrent > juiceTotal)
  34. {
  35. juiceTotal = juiceCurrent;
  36. }
  37. if (juiceCurrent>=juiceTotal)
  38. {
  39. cherryUsed = i;
  40. strawUsed = j;
  41. raspUsed = k;
  42. }
  43. }
  44. }
  45. }
  46. }
  47.  
  48.  
  49.  
  50. Console.WriteLine($"{raspUsed} Raspberries, {strawUsed} Strawberries, {cherryUsed} Cherries. Juice: {juiceTotal} ml.");
  51. }
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement