Advertisement
Guest User

Ugly C# Code

a guest
Aug 27th, 2014
101
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.  
  3. class StarRender
  4. {
  5.     static void Main()
  6.     {
  7.         // Ladies and Gentlemans, look at the ugliest solution I've ever wrote:
  8.         // I have no idea how it even works...
  9.  
  10.         int n = int.Parse(Console.ReadLine());
  11.  
  12.         int width = (2 * n + 1);
  13.         int height = (2 * n - (n / 2 - 1));
  14.  
  15.         int topAndMiddleHeight = n / 2;
  16.         int legsHeight = n / 2 + 1;
  17.  
  18.         int firstDotsLength = n;
  19.  
  20.         Console.WriteLine("{0}*{0}", new string('.', n));
  21.  
  22.         for (int row = 0; row < n / 2-1; row++)
  23.         {
  24.             Console.WriteLine("{0}*{1}*{0}", new string('.', --firstDotsLength), new string('.', 2 * row + 1));
  25.             if (row == n / 2 - 2)
  26.             {
  27.                 Console.WriteLine("{0}{1}{0}", new string('*', row + 3), new string('.', n - 1), new string('*', 2 * row + 3));
  28.             }
  29.         }
  30.  
  31.         for (int row = 0; row < height / 3 - 1; row++)
  32.         {
  33.             int outerDotsCount = row + 1;
  34.             string outerDots = new string('.', outerDotsCount);
  35.             int innerDotsCount = (width - outerDotsCount * 2 - 3) / 2;
  36.             string innerDots = new string('.', innerDotsCount);
  37.             Console.WriteLine("{0}*{1}.{1}*{0}", outerDots, innerDots);
  38.         }
  39.  
  40.         int legsOuterDotsCount = n / 2;
  41.         int middleDotsCount = n / 2 - 1;
  42.         int legsInnerDotsCount = 0;
  43.  
  44.         Console.WriteLine("{0}*{1}*{1}*{0}", new string('.', legsOuterDotsCount), new string('.', middleDotsCount));
  45.  
  46.         for (int row = 0; row < legsHeight - 2; row++)
  47.         {
  48.             legsOuterDotsCount--;
  49.  
  50.             string outerDots = new string('.', legsOuterDotsCount);
  51.             string middleDots = new string('.', middleDotsCount);
  52.             string innerDots = new string('.', legsInnerDotsCount);
  53.  
  54.             Console.Write("{0}*{1}*{2}", outerDots, middleDots, innerDots);
  55.             Console.Write(".");
  56.             Console.WriteLine("{2}*{1}*{0}", outerDots, middleDots, innerDots);
  57.             legsInnerDotsCount++;
  58.         }
  59.  
  60.         Console.WriteLine(
  61.             "{0}{1}{0}",
  62.             new string('*', middleDotsCount+2),
  63.             new string('.', legsInnerDotsCount*2 + 1),
  64.             new string('*', middleDotsCount + 2));
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement