BorislavBorisov

23.01.Arrow - мое решение new string

Oct 4th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 KB | None | 0 0
  1. using System;
  2. class Arrow
  3. {
  4.     static void Main()
  5.     {
  6.         int N = int.Parse(Console.ReadLine());
  7.         int dots = N / 2, leftRightDots = 1, lengthMiddleDots = N * 2 - 5;
  8.         for (int row = 0; row < (N * 2) - 1; row++)
  9.         {
  10.             if (row == 0)
  11.             {
  12.                 Console.Write(new string('.', dots));
  13.                 Console.Write(new string('#', N));
  14.                 Console.Write(new string('.', dots));
  15.                 Console.WriteLine();
  16.             }
  17.             else if (row < N - 1)
  18.             {
  19.                 Console.Write(new string('.', dots));
  20.                 Console.Write("#");
  21.                 Console.Write(new string('.', N - 2));
  22.                 Console.Write("#");
  23.                 Console.Write(new string('.', dots));
  24.                 Console.WriteLine();
  25.             }
  26.             else if (row == N - 1)
  27.             {
  28.                 Console.Write(new string('#', dots + 1));
  29.                 Console.Write(new string('.', N - 2));
  30.                 Console.Write(new string('#', dots + 1));
  31.                 Console.WriteLine();
  32.             }
  33.             else if (row > N - 1 && row < N * 2 - 2)
  34.             {
  35.                 Console.Write(new string('.', leftRightDots));
  36.                 Console.Write("#");
  37.                 Console.Write(new string('.', lengthMiddleDots));
  38.                 Console.Write("#");
  39.                 Console.Write(new string('.', leftRightDots));
  40.                 leftRightDots++;
  41.                 lengthMiddleDots -= 2;
  42.                 Console.WriteLine();
  43.             }
  44.             else
  45.             {
  46.                 Console.Write(new string('.', N - 1));
  47.                 Console.Write("#");
  48.                 Console.Write(new string('.', N - 1));
  49.                 Console.WriteLine();
  50.  
  51.             }
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment