Advertisement
KlimentHristov

Figure.MagicWand

Nov 23rd, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.25 KB | None | 0 0
  1. using System;
  2. class MagicWand
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.         int width = 3 * n + 2;
  8.  
  9.         // first line
  10.         Console.WriteLine("{0}*{0}", new string('.', width / 2));
  11.         // end of first line
  12.         // second line
  13.         int secondDots = width / 2 - 1;
  14.         int secondinnerDots = 1;
  15.         for (int i = 0; i < n / 2 + 1; i++)
  16.         {
  17.             Console.WriteLine("{0}*{1}*{0}", new string('.', secondDots), new string('.', secondinnerDots));
  18.             secondDots--;
  19.             secondinnerDots = secondinnerDots + 2;
  20.         }
  21.         // end of second line
  22.         //third line
  23.         Console.WriteLine("{0}{1}{0}", new string('*', n), new string('.', n + 2));
  24.         // end third line
  25.  
  26.         //fourth line
  27.         int fourtDots = 1;
  28.  
  29.         int innerFourtDots = width - 4;
  30.         for (int i = 0; i < n / 2; i++)
  31.         {
  32.             Console.WriteLine("{0}*{1}*{0}", new string('.', fourtDots), new string('.', innerFourtDots));
  33.             fourtDots++;
  34.             innerFourtDots = innerFourtDots - 2;
  35.         }
  36.         // end fourth line
  37.  
  38.         //Five Magic Line
  39.         int innerFiveDots = 0;
  40.         int innerFiveSecondDots = 0;
  41.         int outFiveDots = n / 2 - 1;
  42.         for (int i = 0; i < n/2-1; i++)
  43.         {
  44.             Console.Write("{0}*{1}*{2}", new string('.', outFiveDots), new string('.', n / 2),new string ('.',innerFiveDots));
  45.             Console.Write("*{0}*",new string ('.',n));
  46.             Console.Write("{2}*{1}*{0}", new string('.', outFiveDots), new string('.', n / 2), new string('.', innerFiveSecondDots));
  47.             innerFiveSecondDots++;
  48.             innerFiveDots++;
  49.             outFiveDots--;
  50.             Console.WriteLine();
  51.         }
  52.  
  53.         Console.WriteLine("*{0}*{1}*{2}*{1}*{0}*",new string ('.',n/2),new string ('.',n/2-1),new string ('.',n));
  54.  
  55.         // before last
  56.         Console.WriteLine("{0}{1}*{2}*{1}{0}", new string ('*',n/2+1), new string ('.',n/2),new string ('.',n));
  57.         // End of wand
  58.         for (int i = 0; i < n; i++)
  59.         {
  60.             Console.WriteLine("{0}*{0}*{0}", new string ('.',n));
  61.         }
  62.         Console.WriteLine("{0}{1}{0}", new string('.', n), new string ('*',n+2));
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement