Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Lasers
  8. {
  9.     class Program
  10.     {
  11.         static string[] cuboids = Console.ReadLine().Split();
  12.         static int width = int.Parse(cuboids[0]);
  13.         static int height = int.Parse(cuboids[1]);  
  14.         static int depth = int.Parse(cuboids[2]);
  15.         static string[] lasers = Console.ReadLine().Split();
  16.         static int laserWidth = int.Parse(lasers[0]);
  17.         static int laserHeight = int.Parse(lasers[1]);
  18.         static int laserDepth = int.Parse(lasers[2]);
  19.         static string[] vectors = Console.ReadLine().Split();
  20.         static int dirWidth = int.Parse(vectors[0]);
  21.         static int dirHeight = int.Parse(vectors[1]);
  22.         static int dirDepth = int.Parse(vectors[2]);
  23.         static bool[, ,] matrix = new bool[width, height, depth];
  24.  
  25.         static void Main(string[] args)
  26.         {
  27.             DeleteEdjes();
  28.             bool opa;
  29.             int oldWidth = 0;
  30.             int oldHeight = 0;
  31.             int oldDepth = 0;
  32.             while (true)
  33.             {
  34.                 CheckForWall(laserWidth,laserHeight,laserDepth);
  35.                 if (matrix[laserWidth,laserHeight,laserDepth] == true)
  36.                 {
  37.                     break;
  38.                 }
  39.                 oldWidth = laserWidth;
  40.                 oldHeight = laserHeight;
  41.                 oldDepth = laserDepth;
  42.                 matrix[laserWidth, laserHeight, laserDepth] = true;
  43.                 laserWidth += dirWidth;
  44.                 laserHeight += dirHeight;
  45.                 laserDepth += dirDepth;
  46.             }
  47.             Console.WriteLine("{0} {1} {2}",oldWidth,oldHeight,oldDepth);
  48.         }
  49.  
  50.         static void CheckForWall(int laserWidth, int laserHeight, int laserDepth)
  51.         {
  52.             if (laserWidth == width - 1 || laserWidth == 0)
  53.             {
  54.                 dirWidth *= -1;
  55.             }
  56.             if (laserHeight == height -1 || laserHeight == 0)
  57.             {
  58.                 dirHeight *= -1;
  59.             }
  60.             if (laserDepth == depth - 1 || laserDepth == 0)
  61.             {
  62.                 dirDepth *= -1;
  63.             }
  64.         }
  65.  
  66.         static void DeleteEdjes()
  67.         {
  68.             int curWidth = 0;
  69.             int curHeight = 0;
  70.             int curDepth = 0;
  71.             for (int i = 0; i < height; i++)
  72.             {
  73.                 matrix[curWidth, curHeight, curDepth] = true;
  74.                 curHeight++;
  75.             }
  76.             curHeight = 0;
  77.             for (int i = 1; i < width; i++)
  78.             {
  79.                 matrix[curWidth, curHeight, curDepth] = true;
  80.                 curWidth++;
  81.             }
  82.             curWidth = 0;
  83.             for (int i = 1; i < depth; i++)
  84.             {
  85.                 matrix[curWidth, curHeight, curDepth] = true;
  86.                 curDepth++;                
  87.             }
  88.             curDepth = depth - 1;
  89.             for (int i = 1; i < width; i++)
  90.             {
  91.                 matrix[curWidth, curHeight, curDepth] = true;
  92.                 curWidth++;
  93.             }
  94.             curDepth = 0;
  95.             for (int i = 1; i < depth; i++)
  96.             {
  97.                 matrix[curWidth, curHeight, curDepth] = true;
  98.                 curDepth++;
  99.             }
  100.             curWidth = width-1;
  101.             curHeight = 0;
  102.             curDepth = 0;
  103.             for (int i = 1; i < height; i++)
  104.             {
  105.                 matrix[curWidth, curHeight, curDepth] = true;
  106.                 curHeight++;              
  107.             }
  108.             curHeight = 0;
  109.             curDepth = depth-1;
  110.             for (int i = 1; i < height; i++)
  111.             {
  112.                 matrix[curWidth, curHeight, curDepth] = true;
  113.                 curHeight++;
  114.             }
  115.             curWidth = 0;
  116.             curHeight = 0;
  117.             for (int i = 1; i < height; i++)
  118.             {
  119.                 matrix[curWidth, curHeight, curDepth] = true;
  120.                 curHeight++;
  121.             }
  122.             curWidth = 0;
  123.             curHeight = height-1;
  124.             curDepth = 0;
  125.             for (int i = 1; i < width; i++)
  126.             {
  127.                 matrix[curWidth, curHeight, curDepth] = true;
  128.                 curWidth++;
  129.             }
  130.             curWidth = 0;
  131.             curDepth = 0;
  132.             for (int i = 1; i < depth; i++)
  133.             {
  134.                 matrix[curWidth, curHeight, curDepth] = true;
  135.                 curDepth++;
  136.             }
  137.             curWidth = width-1;
  138.             curDepth = 0;
  139.             for (int i = 1; i < depth; i++)
  140.             {
  141.                 matrix[curWidth, curHeight, curDepth] = true;
  142.                 curDepth++;
  143.             }
  144.             curWidth = 0;
  145.             curDepth = depth-1;
  146.             for (int i = 1; i < width; i++)
  147.             {
  148.                 matrix[curWidth, curHeight, curDepth] = true;
  149.                 curWidth++;
  150.             }
  151.         }
  152.     }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement