Advertisement
NelIfandieva

Bradva_OneLoopSolution

Jan 14th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.74 KB | None | 0 0
  1.             int scale = int.Parse(Console.ReadLine());
  2.  
  3.             int totalHeight = scale * 2 - 1;
  4.             int firstHeight = scale;
  5.             int midHeight = scale / 2;
  6.             int lastStart = firstHeight + midHeight;
  7.  
  8.             // Here follow the variables for the Upper part
  9.  
  10.             char backgroundHyphen = '-';
  11.             int bckgrndHyphenStartNum = 3 * scale;
  12.  
  13.             char axeSymbol = '*';
  14.             int axeUpperNum = 1;
  15.  
  16.             char innerSymbol = '-';
  17.             int innerUpperNum = 0;
  18.  
  19.             int bckgrndHyphenEndNum = scale * 2 - 2;
  20.  
  21.             // Here follow the variables for the middle part
  22.  
  23.             char handleSymbol = '*';
  24.             int handleSymbolNum = 3 * scale;
  25.  
  26.             int axeMidNum = 1;
  27.  
  28.             char inner = '-';
  29.             int innerMidNum = scale - 1;
  30.  
  31.             // And here are the variables for the last/lower part
  32.  
  33.             int backgroundLowerNum = scale * 3;
  34.  
  35.             int axeLowerNum = 1;
  36.             int innerLowerNum = scale - 1;
  37.  
  38.             char endSymbol = '-';
  39.             int endNum = scale - 1;
  40.  
  41.             // Here starts the drawing.
  42.  
  43.             for (int i = 1; i <= totalHeight; i++)
  44.             {
  45.                 if(i <= firstHeight) // draw upper
  46.                 {
  47.                     Console.WriteLine("{0}{1}{2}{1}{3}", new string(backgroundHyphen, bckgrndHyphenStartNum), new string(axeSymbol, axeUpperNum), new string(innerSymbol, innerUpperNum), new string(endSymbol, bckgrndHyphenEndNum));
  48.                     innerUpperNum++;
  49.                     bckgrndHyphenEndNum--;
  50.                 }
  51.                 else if(i >= lastStart) // draw last part
  52.                 {
  53.                     if (i < totalHeight)
  54.                     {
  55.                         Console.WriteLine("{0}{1}{2}{1}{3}", new string(backgroundHyphen, backgroundLowerNum), new string(axeSymbol, axeLowerNum), new string(inner, innerLowerNum), new string(endSymbol, endNum));
  56.                         backgroundLowerNum--;
  57.                         innerLowerNum += 2;
  58.                         endNum--;
  59.                     }
  60.                     else
  61.                     {
  62.                         int width = scale * 5;
  63.                         int axeSymbolNum = (width - ((backgroundLowerNum - 1) + endNum)) - 1;
  64.                         Console.WriteLine("{0}{1}{2}", new string(backgroundHyphen, backgroundLowerNum), new string(axeSymbol, axeSymbolNum), new string(endSymbol, endNum));
  65.                     }
  66.                 }
  67.                 else // draw handle
  68.                 {
  69.                     Console.WriteLine("{0}{1}{2}{1}{2}", new string(handleSymbol, handleSymbolNum), new string(axeSymbol, axeMidNum), new string(inner, innerMidNum));
  70.                 }
  71.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement