Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fit Box in Box
- //Nakov likes boxes. Ha has many boxes at home. To save space he often puts his boxes one inside another. A box can fit inside //another box if the size of the smaller box is smaller than the size of the bigger box in all dimensions at the same time. Of //course, boxes can be rotated to fit one inside another. Here are few examples:
- //• (5, 1, 6) fits naturally in (6, 2, 9), because 5 < 6 and 1 < 2 and 6 < 9
- //• (5, 1, 6) fits in (2, 7, 6) after rotating the second box to (6, 2, 7)
- //• (7, 8, 1) cannot fit in (12, 7, 3) even after rotating
- //• (6, 2, 9) cannot fit in (5, 1, 6) even after rotating
- //You are given the sizes of two boxes (width, height and depth). Write a program to check whether the boxes can fit one inside //another and how exactly. Print the smaller box first, exactly as it is given in the input (without rotating), followed by "<" and //the larger box (eventually rotated) to fit each of the dimensions. Print all possible ways to put the smaller box into the larger //box. In case there is no smaller box, print nothing. See the examples below to catch the idea.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FitBoxInBox
- {
- class Program
- {
- static void Main(string[] args)
- {
- int w1 = int.Parse(Console.ReadLine());
- int h1 = int.Parse(Console.ReadLine());
- int d1 = int.Parse(Console.ReadLine());
- int w2 = int.Parse(Console.ReadLine());
- int h2 = int.Parse(Console.ReadLine());
- int d2 = int.Parse(Console.ReadLine());
- int firstBoxBigger = w1 + h1 + d1;
- int secondBoxBigger = w2 + h2 + d2;
- if (firstBoxBigger > secondBoxBigger)
- {
- if (w2 < w1 && h2 < h1 && d2 < d1)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})",w2,h2,d2,w1,h1,d1);
- }
- if (w2 < w1 && h2 < d1 && d2 < h1)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, w1, d1, h1);
- }
- if (w2 < h1 && h2 < w1 && d2 < d1)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, h1, w1, d1);
- }
- if (w2 < h1 && h2 < d1 && d2 < w1)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, h1, d1, w1);
- }
- if (w2 < d1 && h2 < w1 && d2 < h1)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, d1, w1, h1);
- }
- if (w2 < d1 && h2 < h1 && d2 < w1)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, d1, h1, w1);
- }
- }
- if (firstBoxBigger < secondBoxBigger)
- {
- if (w1 < w2 && h1 < h2 && d1 < d2)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, w2, h2, d2);
- }
- if (w1 < w2 && h1 < d2 && d1 < h2)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, w2, d2, h2);
- }
- if (w1 < h2 && h1 < w2 && d1 < d2)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, h2, w2, d2);
- }
- if (w1 < h2 && h1 < d2 && d1 < w2)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, h2, d2, w2);
- }
- if (w1 < d2 && h1 < w2 && d1 < h2)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, d2, w2, h2);
- }
- if (w1 < d2 && h1 < h2 && d1 < w2)
- {
- Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, d2, h2, w2);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement