Advertisement
kalinkata

KspichaniaBoats

Apr 15th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.26 KB | None | 0 0
  1. using System;
  2.  
  3. class KaspichaniaBoats
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.  
  9.         int width = n * 2 + 1;
  10.         int height = 6 + ((n - 3) / 2) * 3;
  11.  
  12.         int[,] matrix = new int[height, width];
  13.  
  14.         int x = height / 3;
  15.         int y = width / 2;
  16.  
  17.         int currentCol = y;
  18.         int currentRow = 0;
  19.  
  20.         while (true)
  21.         {
  22.             matrix[currentRow, currentCol] = 1;
  23.  
  24.             currentCol++;
  25.             currentRow++;
  26.  
  27.             if (currentRow == x * 2)
  28.             {
  29.                 currentCol--;
  30.                 currentRow--;
  31.                 break;
  32.             }
  33.         }
  34.  
  35.         while (true)
  36.         {
  37.             matrix[currentRow, currentCol] = 1;
  38.  
  39.             currentCol--;
  40.             currentRow++;
  41.  
  42.             if (currentCol == y + n / 2 - 1)
  43.             {
  44.                 currentCol++;
  45.                 currentRow--;
  46.                 break;
  47.             }
  48.         }
  49.  
  50.         while (true)
  51.         {
  52.             matrix[currentRow, currentCol] = 1;
  53.  
  54.             currentCol--;
  55.  
  56.             if (currentCol == n / 2 + 1)
  57.             {
  58.                 //currentCol++;
  59.                 //currentRow--;
  60.                 break;
  61.             }
  62.         }
  63.  
  64.         while (true)
  65.         {
  66.             matrix[currentRow, currentCol] = 1;
  67.  
  68.             currentCol--;
  69.             currentRow--;
  70.  
  71.             if (currentRow == x * 2 - 2)
  72.             {
  73.                 currentCol++;
  74.                 currentRow++;
  75.                 break;
  76.             }
  77.         }
  78.  
  79.         while (true)
  80.         {
  81.             matrix[currentRow, currentCol] = 1;
  82.  
  83.             currentCol++;
  84.             currentRow--;
  85.  
  86.             if (currentCol == y + 1)
  87.             {
  88.                 currentCol--;
  89.                 currentRow++;
  90.                 break;
  91.             }
  92.         }
  93.  
  94.         while (true)
  95.         {
  96.             matrix[currentRow, currentCol] = 1;
  97.  
  98.             currentRow++;
  99.  
  100.             if (currentRow == height)
  101.             {
  102.                 currentRow--;
  103.                 break;
  104.             }
  105.         }
  106.  
  107.         while (true)
  108.         {
  109.             matrix[currentRow, currentCol] = 1;
  110.  
  111.             currentRow--;
  112.  
  113.             if (currentRow == x * 2 - 1)
  114.             {
  115.                 //currentRow++;
  116.                 break;
  117.             }
  118.         }
  119.  
  120.         while (true)
  121.         {
  122.             matrix[currentRow, currentCol] = 1;
  123.  
  124.             currentCol++;
  125.  
  126.             if (currentCol == width)
  127.             {
  128.                 currentCol--;
  129.                 break;
  130.             }
  131.         }
  132.  
  133.         while (true)
  134.         {
  135.             matrix[currentRow, currentCol] = 1;
  136.  
  137.             currentCol--;
  138.  
  139.             if (currentCol == 0)
  140.             {
  141.                 currentCol++;
  142.                 break;
  143.             }
  144.         }
  145.  
  146.         for (int row = 0; row < height; row++)
  147.         {
  148.             for (int col = 0; col < width; col++)
  149.             {
  150.                 if (matrix[row, col] == 0)
  151.                 {
  152.                     Console.Write('.');
  153.                 }
  154.                 if (matrix[row, col] == 1)
  155.                 {
  156.                     Console.Write('*');
  157.                 }
  158.             }
  159.             Console.WriteLine();
  160.         }
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement