BorislavBorisov

02.01.Bat Goiko Tawer мое добро решение

Dec 21st, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2.  
  3. class BatCoikosTower
  4. {
  5.     static void Main()
  6.     {
  7.         int N = int.Parse(Console.ReadLine());
  8.         char[,] matrix = new char[N, N * 2];
  9.         int middleDots = 1, counter = 2;
  10.         bool isMiddle = false;
  11.  
  12.         for (int row = 0; row < matrix.GetLength(0); row++)
  13.         {
  14.             for (int col = 0; col < matrix.GetLength(1); col++)
  15.             {
  16.                 if (col < (N - row - 1))
  17.                 {
  18.                     matrix[row, col] = '.';
  19.                 }
  20.                 else if(col == N - row - 1)
  21.                 {
  22.                     matrix[row, col] = '/';
  23.                 }
  24.                 else if (col == N + row)
  25.                 {
  26.                     matrix[row, col] = '\\';
  27.                 }
  28.                 else if (col > N + row)
  29.                 {
  30.                     matrix[row, col] = '.';
  31.                 }
  32.                 else
  33.                 {
  34.                     if (middleDots == row)
  35.                     {
  36.                         matrix[row, col] = '-';
  37.                         isMiddle = true;
  38.                     }
  39.                     else
  40.                     {
  41.                         matrix[row,col] = '.';
  42.                     }
  43.                 }
  44.             }
  45.             if (isMiddle)
  46.             {
  47.                 middleDots += counter;
  48.                 counter++;
  49.                 isMiddle = false;
  50.             }
  51.         }
  52.         for (int row = 0; row < matrix.GetLength(0); row++)
  53.         {
  54.             for (int col = 0; col < matrix.GetLength(1); col++)
  55.             {
  56.                 Console.Write(matrix[row,col]);
  57.             }
  58.             Console.WriteLine();
  59.         }
  60.        
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment