iliya87

01.FitInBox

Mar 27th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.42 KB | None | 0 0
  1. using System;
  2. class FitInBox
  3. {
  4.     static void Main()
  5.     {
  6.         int firstBoxSide1 = int.Parse(Console.ReadLine());
  7.         int firstBoxSide2 = int.Parse(Console.ReadLine());
  8.         int firstBoxSide3 = int.Parse(Console.ReadLine());
  9.         int secondBoxSide1 = int.Parse(Console.ReadLine());
  10.         int secondBoxSide2 = int.Parse(Console.ReadLine());
  11.         int secondBoxSide3 = int.Parse(Console.ReadLine());
  12.  
  13.         //TRUE if firstBox is bigger than the second.
  14.         //FALSE if secondBox is begger than the first.
  15.         bool fBigger = Math.Max(firstBoxSide3, Math.Max(firstBoxSide1, firstBoxSide2)) >
  16.                            Math.Max(secondBoxSide3, Math.Max(secondBoxSide1, secondBoxSide2));
  17.  
  18.         //Making the firstBox to be always bigger than the second.
  19.         if (!fBigger)
  20.         {
  21.             secondBoxSide1 = secondBoxSide1 + firstBoxSide1;
  22.             firstBoxSide1 = secondBoxSide1 - firstBoxSide1;
  23.             secondBoxSide1 = secondBoxSide1 - firstBoxSide1;
  24.  
  25.             secondBoxSide2 = secondBoxSide2 + firstBoxSide2;
  26.             firstBoxSide2 = secondBoxSide2 - firstBoxSide2;
  27.             secondBoxSide2 = secondBoxSide2 - firstBoxSide2;
  28.  
  29.             secondBoxSide3 = secondBoxSide3 + firstBoxSide3;
  30.             firstBoxSide3 = secondBoxSide3 - firstBoxSide3;
  31.             secondBoxSide3 = secondBoxSide3 - firstBoxSide3;
  32.         }
  33.        
  34.         if (firstBoxSide1 > secondBoxSide1 &&  //1 2 3 > 1 2 3
  35.             firstBoxSide2 > secondBoxSide2 &&
  36.             firstBoxSide3 > secondBoxSide3)
  37.         {
  38.             Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", secondBoxSide1, secondBoxSide2, secondBoxSide3, firstBoxSide1, firstBoxSide2, firstBoxSide3);
  39.         }
  40.         if (firstBoxSide1 > secondBoxSide1 && // 1 3 2 > 1 2 3
  41.                 firstBoxSide3 > secondBoxSide2 &&
  42.                 firstBoxSide2 > secondBoxSide3)
  43.         {
  44.             Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", secondBoxSide1, secondBoxSide2, secondBoxSide3, firstBoxSide1, firstBoxSide3, firstBoxSide2);
  45.         }
  46.         if (firstBoxSide2 > secondBoxSide1 && // 2 1 3 > 1 2 3
  47.                  firstBoxSide1 > secondBoxSide2 &&
  48.                  firstBoxSide3 > secondBoxSide3)
  49.         {
  50.             Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", secondBoxSide1, secondBoxSide2, secondBoxSide3, firstBoxSide2, firstBoxSide1, firstBoxSide3);
  51.         }
  52.         if (firstBoxSide2 > secondBoxSide1 && // 2 3 1 > 1 2 3
  53.                  firstBoxSide3 > secondBoxSide2 &&
  54.                  firstBoxSide1 > secondBoxSide3)
  55.         {
  56.             Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", secondBoxSide1, secondBoxSide2, secondBoxSide3, firstBoxSide2, firstBoxSide3, firstBoxSide1);
  57.         }
  58.         if (firstBoxSide3 > secondBoxSide1 && // 3 1 2 > 1 2 3
  59.                  firstBoxSide1 > secondBoxSide2 &&
  60.                  firstBoxSide2 > secondBoxSide3)
  61.         {
  62.             Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", secondBoxSide1, secondBoxSide2, secondBoxSide3, firstBoxSide3, firstBoxSide1, firstBoxSide2);
  63.         }
  64.         if (firstBoxSide3 > secondBoxSide1 && // 3 2 1 > 1 2 3
  65.                  firstBoxSide2 > secondBoxSide2 &&
  66.                  firstBoxSide1 > secondBoxSide3)
  67.         {
  68.             Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", secondBoxSide1, secondBoxSide2, secondBoxSide3, firstBoxSide3, firstBoxSide2, firstBoxSide1);
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment