Advertisement
dimipan80

Exam 9. Fit Box in Box

Jun 23rd, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.39 KB | None | 0 0
  1. namespace _1.FitBoxInBox
  2. {
  3.     using System;
  4.  
  5.     public class FitBoxInBox
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             checked
  10.             {
  11.                 int width1 = int.Parse(Console.ReadLine());
  12.                 int height1 = int.Parse(Console.ReadLine());
  13.                 int depth1 = int.Parse(Console.ReadLine());
  14.                 int width2 = int.Parse(Console.ReadLine());
  15.                 int height2 = int.Parse(Console.ReadLine());
  16.                 int depth2 = int.Parse(Console.ReadLine());                
  17.                
  18.                 int sumDims1 = width1 + height1 + depth1;
  19.                 int sumDims2 = width2 + height2 + depth2;
  20.                 if (sumDims2 > sumDims1)
  21.                 {
  22.                     ComparingFitsOfTwoBoxesAndPrintResults(width1, height1, depth1, width2, height2, depth2);
  23.                 }
  24.                 else
  25.                 {
  26.                     ComparingFitsOfTwoBoxesAndPrintResults(width2, height2, depth2, width1, height1, depth1);
  27.                 }
  28.             }
  29.         }
  30.  
  31.         private static void ComparingFitsOfTwoBoxesAndPrintResults(int w1, int h1, int d1, int w2, int h2, int d2)
  32.         {
  33.             checked
  34.             {
  35.                 if (w2 > w1 && h2 > h1 && d2 > d1)
  36.                 {
  37.                     Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, w2, h2, d2);
  38.                 }
  39.  
  40.                 if (w2 > w1 && d2 > h1 && h2 > d1)
  41.                 {
  42.                     Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, w2, d2, h2);
  43.                 }
  44.  
  45.                 if (h2 > w1 && w2 > h1 && d2 > d1)
  46.                 {
  47.                     Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, h2, w2, d2);
  48.                 }
  49.  
  50.                 if (h2 > w1 && d2 > h1 && w2 > d1)
  51.                 {
  52.                     Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, h2, d2, w2);
  53.                 }
  54.  
  55.                 if (d2 > w1 && w2 > h1 && h2 > d1)
  56.                 {
  57.                     Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, d2, w2, h2);
  58.                 }
  59.  
  60.                 if (d2 > w1 && h2 > h1 && w2 > d1)
  61.                 {
  62.                     Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, d2, h2, w2);
  63.                 }
  64.             }
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement