stoyanmkd

Tables - masi

Dec 19th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2.  
  3. class Tables_2
  4. {
  5.     static void Main()
  6.     {
  7.         int bundle1 = int.Parse(Console.ReadLine());
  8.         int bundle2 = int.Parse(Console.ReadLine());
  9.         int bundle3 = int.Parse(Console.ReadLine());
  10.         int bundle4 = int.Parse(Console.ReadLine());
  11.         int tableTops = int.Parse(Console.ReadLine());
  12.         int tablesToDo = int.Parse(Console.ReadLine());
  13.  
  14.         int allLegs = bundle1 + (bundle2 * 2) + (bundle3 * 3) + (bundle4 * 4);
  15.         int LeftLegs1 = allLegs % 4;
  16.         int LegsForDoneTables = allLegs / 4;
  17.  
  18.         int tablesMade = Math.Min(LegsForDoneTables, tableTops);
  19.  
  20.         if (tablesMade > tablesToDo)
  21.         {
  22.             int topsLeft = tableTops - tablesToDo;
  23.             if (topsLeft < 0)
  24.             {
  25.                 topsLeft = 0;
  26.             }
  27.             int legsLeft = allLegs - tablesToDo*4;
  28.             if (legsLeft < 0)
  29.             {
  30.                 legsLeft = 0;
  31.             }
  32.             Console.WriteLine("more: {0}", tablesMade - tablesToDo);
  33.             Console.WriteLine("tops left: {0}, legs left: {1}", topsLeft, legsLeft);
  34.         }
  35.         else if (tablesMade < tablesToDo)
  36.         {
  37.             int topsNeeded = tablesToDo - tableTops;
  38.             if (topsNeeded < 0)
  39.             {
  40.                 topsNeeded = 0;
  41.             }
  42.             int legsNeeded = (tablesToDo*4) - allLegs;
  43.             if (legsNeeded < 0)
  44.             {
  45.                 legsNeeded = 0;
  46.             }
  47.             Console.WriteLine("less: {0}", tablesMade - tablesToDo);
  48.             Console.WriteLine("tops needed: {0}, legs needed: {1}", topsNeeded, legsNeeded);
  49.         }
  50.         else if (tablesMade == tablesToDo)
  51.         {
  52.           Console.WriteLine("Just enough tables made: {0}", tablesMade);  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment