fbinnzhivko

01.01 Fit Box inbox

Apr 15th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. class FitBoxInBox
  3. {
  4.     static void Main()
  5.     {
  6.         int w1 = int.Parse(Console.ReadLine());
  7.         int h1 = int.Parse(Console.ReadLine());
  8.         int d1 = int.Parse(Console.ReadLine());
  9.  
  10.         int w2 = int.Parse(Console.ReadLine());
  11.         int h2 = int.Parse(Console.ReadLine());
  12.         int d2 = int.Parse(Console.ReadLine());
  13.  
  14.         // Try to fit the first box inside the second box (6 possibilities)
  15.         CheckBoxes(w1, h1, d1, w2, h2, d2);
  16.         CheckBoxes(w1, h1, d1, w2, d2, h2);
  17.         CheckBoxes(w1, h1, d1, h2, w2, d2);
  18.         CheckBoxes(w1, h1, d1, h2, d2, w2);
  19.         CheckBoxes(w1, h1, d1, d2, w2, h2);
  20.         CheckBoxes(w1, h1, d1, d2, h2, w2);
  21.  
  22.         // Try to fit the second box inside the first box (6 possibilities)
  23.         CheckBoxes(w2, h2, d2, w1, h1, d1);
  24.         CheckBoxes(w2, h2, d2, w1, d1, h1);
  25.         CheckBoxes(w2, h2, d2, h1, w1, d1);
  26.         CheckBoxes(w2, h2, d2, h1, d1, w1);
  27.         CheckBoxes(w2, h2, d2, d1, w1, h1);
  28.         CheckBoxes(w2, h2, d2, d1, h1, w1);
  29.     }
  30.  
  31.     private static void CheckBoxes(
  32.         int firstWidth, int firstHeight, int firstDepth,
  33.         int secondWidth, int secondHeight, int secondDepth)
  34.     {
  35.         if (firstWidth < secondWidth && firstHeight < secondHeight && firstDepth < secondDepth)
  36.         {
  37.             Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})",
  38.                 firstWidth, firstHeight, firstDepth, secondWidth, secondHeight, secondDepth);
  39.         }
  40.     }
  41. }
Add Comment
Please, Sign In to add comment