Advertisement
KlimentHristov

Figure.Star

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