Advertisement
dimipan80

C#Exams 1. Fit Box in Box (on Java Code)

Aug 25th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class _1_FitBoxInBox {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.         Scanner scan = new Scanner(System.in);
  8.         int width1 = scan.nextInt();
  9.         int height1 = scan.nextInt();
  10.         int depth1 = scan.nextInt();
  11.         int width2 = scan.nextInt();
  12.         int height2 = scan.nextInt();
  13.         int depth2 = scan.nextInt();
  14.  
  15.         int sumBox1 = width1 + height1 + depth1;
  16.         int sumBox2 = width2 + height2 + depth2;
  17.         if (sumBox2 > sumBox1) {
  18.             checkToFitTheSmallerBoxInTheBiggerBoxInAllPossibleWaysAndPrintResult(
  19.                     width1, height1, depth1, width2, height2, depth2);
  20.         } else if (sumBox1 > sumBox2) {
  21.             checkToFitTheSmallerBoxInTheBiggerBoxInAllPossibleWaysAndPrintResult(
  22.                     width2, height2, depth2, width1, height1, depth1);
  23.         }
  24.     }
  25.  
  26.     private static void checkToFitTheSmallerBoxInTheBiggerBoxInAllPossibleWaysAndPrintResult(
  27.             int w1, int h1, int d1, int w2, int h2, int d2) {
  28.         // TODO Auto-generated method stub
  29.         if (w1 < w2 && h1 < h2 && d1 < d2) {
  30.             System.out.printf("(%d, %d, %d) < (%d, %d, %d)\n", w1, h1, d1, w2,
  31.                     h2, d2);
  32.         }
  33.  
  34.         if (w1 < w2 && h1 < d2 && d1 < h2) {
  35.             System.out.printf("(%d, %d, %d) < (%d, %d, %d)\n", w1, h1, d1, w2,
  36.                     d2, h2);
  37.         }
  38.  
  39.         if (w1 < h2 && h1 < w2 && d1 < d2) {
  40.             System.out.printf("(%d, %d, %d) < (%d, %d, %d)\n", w1, h1, d1, h2,
  41.                     w2, d2);
  42.         }
  43.  
  44.         if (w1 < h2 && h1 < d2 && d1 < w2) {
  45.             System.out.printf("(%d, %d, %d) < (%d, %d, %d)\n", w1, h1, d1, h2,
  46.                     d2, w2);
  47.         }
  48.  
  49.         if (w1 < d2 && h1 < w2 && d1 < h2) {
  50.             System.out.printf("(%d, %d, %d) < (%d, %d, %d)\n", w1, h1, d1, d2,
  51.                     w2, h2);
  52.         }
  53.  
  54.         if (w1 < d2 && h1 < h2 && d1 < w2) {
  55.             System.out.printf("(%d, %d, %d) < (%d, %d, %d)\n", w1, h1, d1, d2,
  56.                     h2, w2);
  57.         }
  58.     }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement