Advertisement
KlimentHristov

Figure.HeadPhone

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