fbinnzhivko

03.01 Headphones

Apr 2nd, 2016
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main(string[] args)
  5.     {
  6.         int diameter = int.Parse(Console.ReadLine());
  7.  
  8.         int width = 2 * diameter + 1;
  9.         int height = 2 * diameter;
  10.         int monkc = diameter + 2;
  11.  
  12.         int dashesc = (width - monkc) / 2;
  13.  
  14.         string dashes1 = new String('-', dashesc);
  15.         string astrikos1 = new String('*', monkc);
  16.  
  17.         Console.WriteLine("{0}{1}{0}", dashes1, astrikos1);
  18.         // handles height
  19.         int handlesHeight = diameter - 1;
  20.  
  21.         int dashoutc = (width - monkc) / 2;
  22.         int dashinc = (diameter);
  23.  
  24.         string dashesout = new String('-', dashoutc);
  25.         string dashin = new String('-', dashinc);
  26.  
  27.         for (int i = 0; i < handlesHeight; i++)
  28.         {
  29.             Console.WriteLine("{0}*{1}*{0}", dashesout, dashin);
  30.         }
  31.  
  32.         // speakers
  33.         int numberOfdashOutc = (width - monkc) / 2;
  34.         int numberOfdashInc = (diameter);
  35.         int numberOfStarsc = 1;
  36.  
  37.         for (; numberOfStarsc < diameter;)
  38.         {
  39.             string numberOfdashOut = new String('-', numberOfdashOutc);
  40.             string numberOfdashIn = new String('-', numberOfdashInc);
  41.             string numberOfStars = new String('*', numberOfStarsc);
  42.  
  43.             Console.WriteLine("{0}{1}{2}{1}{0}", numberOfdashOut, numberOfStars, numberOfdashIn);
  44.  
  45.             if (numberOfStarsc < diameter)
  46.             {
  47.  
  48.                 numberOfdashOutc--;
  49.                 numberOfStarsc += 2;
  50.                 numberOfdashInc -= 2;
  51.             }
  52.  
  53.         }
  54.  
  55.         for (; numberOfStarsc <= diameter && numberOfStarsc >= 1;)
  56.         {
  57.             string numberOfdashOut = new String('-', numberOfdashOutc);
  58.             string numberOfdashIn = new String('-', numberOfdashInc);
  59.             string numberOfStars = new String('*', numberOfStarsc);
  60.  
  61.             Console.WriteLine("{0}{1}{2}{1}{0}", numberOfdashOut, numberOfStars, numberOfdashIn);
  62.  
  63.  
  64.             numberOfdashOutc++;
  65.             numberOfStarsc -= 2;
  66.             numberOfdashInc += 2;
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment