Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. int minKozunaci = 0;
  2.             int maxKozunaci = 100;
  3.             int minIngredients = 1;
  4.             int maxIngredients = 10000;
  5.  
  6.             int kozunaciCount = int.Parse(Console.ReadLine());
  7.            
  8.  
  9.             int sugar = 950;
  10.             int flour = 750;
  11.  
  12.             if (kozunaciCount < minKozunaci || kozunaciCount > maxKozunaci)
  13.             {
  14.                 return;
  15.             }
  16.  
  17.             //if (quantitySugar < minIngredients || quantitySugar > maxIngredients)
  18.             //{
  19.             //    return;
  20.             //}
  21.  
  22.             //if (quantityFlour < minIngredients || quantityFlour > maxIngredients)
  23.             //{
  24.             //    return;
  25.             //}
  26.  
  27.             int allSugar = 0;
  28.             int allFlour = 0;
  29.            
  30.             int maxSugar = 0;
  31.             int maxFlour = 0;
  32.  
  33.             while (kozunaciCount > 0)
  34.             {
  35.                 int quantitySugar = int.Parse(Console.ReadLine());
  36.                 int quantityFlour = int.Parse(Console.ReadLine());
  37.  
  38.                 if (quantitySugar > maxSugar)
  39.                 {
  40.                     maxSugar = quantitySugar;
  41.                 }
  42.  
  43.                 if (quantityFlour > maxFlour)
  44.                 {
  45.                     maxFlour = quantityFlour;
  46.                 }
  47.  
  48.                 allSugar += quantitySugar;
  49.                 allFlour += quantityFlour;
  50.  
  51.                 kozunaciCount--;
  52.             }
  53.  
  54.             double calc1 = (double)allSugar / sugar;
  55.             double sugarPakcs = Math.Ceiling(calc1);
  56.  
  57.             double calc2 = (double)allFlour / flour;
  58.             double flourPakcs = Math.Ceiling(calc2);
  59.  
  60.             Console.WriteLine($"Sugar: {sugarPakcs}");
  61.             Console.WriteLine($"Flour: {flourPakcs}");
  62.             Console.WriteLine($"Max used flour is {maxFlour} grams, max used sugar is {maxSugar} grams.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement