Advertisement
kirchev95

KaspichaniaBoats

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