vonko1988

c#Telerik_Logo

Apr 28th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.27 KB | None | 0 0
  1. using System;
  2.  
  3. class TelerikLogo
  4. {
  5.     static void Main()
  6.     {
  7.         int x = int.Parse(Console.ReadLine());
  8.         int y = x;
  9.         int z = x / 2 + 1;
  10.  
  11.         int rows = 2 * x + x - 2;
  12.         int elementsOnLine = rows;
  13.         int leftRightPointsTop = -1;
  14.         int middlePointsTop = 2 * x - 3;
  15.  
  16.         //Top section of the figure(the rows <= z)
  17.         for (int i = 1; i <= z; i++)
  18.         {
  19.             if (z - i > 0)
  20.             {
  21.                 Console.Write(new string('.', z - i));
  22.             }
  23.  
  24.             if (i <= z)
  25.             {
  26.                 Console.Write('*');
  27.             }
  28.  
  29.             if (i > 1)
  30.             {
  31.                 Console.Write(new string('.', leftRightPointsTop));
  32.             }
  33.  
  34.             if (i > 1)
  35.             {
  36.                 Console.Write('*');
  37.             }
  38.  
  39.             if (middlePointsTop > 0)
  40.             {
  41.                 Console.Write(new string('.', middlePointsTop));
  42.             }
  43.  
  44.             Console.Write('*');
  45.  
  46.             if (i > 1)
  47.             {
  48.                 Console.Write(new string('.', leftRightPointsTop));
  49.             }
  50.  
  51.             if (i > 1)
  52.             {
  53.                 Console.Write('*');
  54.             }
  55.  
  56.             if (z - i > 0)
  57.             {
  58.                 Console.Write(new string('.', z - i));
  59.             }
  60.  
  61.             leftRightPointsTop += 2;
  62.             middlePointsTop -= 2;
  63.             Console.WriteLine();
  64.         }
  65.  
  66.         //Second-top-section(from y to z)
  67.         int counter = 0;
  68.  
  69.         if (x % 2 != 0)
  70.         {
  71.             counter = x;
  72.         }
  73.         else
  74.         {
  75.             counter = x + 1;
  76.         }
  77.  
  78.         for (int i = 1; i < y - z; i++)
  79.         {
  80.             Console.Write(new string('.', counter));
  81.  
  82.             Console.Write('*');
  83.  
  84.             Console.Write(new string('.', middlePointsTop));
  85.  
  86.             Console.Write('*');
  87.  
  88.             Console.Write(new string('.', counter));
  89.  
  90.             counter++;
  91.             middlePointsTop -= 2;
  92.             Console.WriteLine();
  93.         }
  94.  
  95.         //Middle section
  96.         int leftRightPointsMiddle = elementsOnLine / 2;
  97.         int middlePointsMiddle = -1;
  98.  
  99.         for (int i = 1; i <= x; i++)
  100.         {
  101.  
  102.             Console.Write(new string('.', leftRightPointsMiddle));
  103.  
  104.  
  105.             Console.Write("*");
  106.  
  107.             if (i > 1)
  108.             {
  109.                 Console.Write(new string('.', middlePointsMiddle));
  110.  
  111.                 Console.Write("*");
  112.             }
  113.  
  114.             Console.Write(new string('.', leftRightPointsMiddle));
  115.  
  116.             leftRightPointsMiddle--;
  117.             middlePointsMiddle += 2;
  118.             Console.WriteLine();
  119.         }
  120.  
  121.         leftRightPointsMiddle += 2;
  122.         middlePointsMiddle -= 4;
  123.  
  124.         //Bottom section
  125.         for (int i = 2; i <= x; i++)
  126.         {
  127.             Console.Write(new string('.', leftRightPointsMiddle));
  128.  
  129.             Console.Write("*");
  130.  
  131.             if (i < x)
  132.             {
  133.                 Console.Write(new string('.', middlePointsMiddle));
  134.  
  135.                 Console.Write("*");
  136.             }
  137.  
  138.             Console.Write(new string('.', leftRightPointsMiddle));
  139.  
  140.             leftRightPointsMiddle++;
  141.  
  142.             middlePointsMiddle -= 2;
  143.  
  144.             Console.WriteLine();
  145.         }
  146.     }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment