stefan1919

Headphones

Aug 2nd, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class ConsoleApplication1
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.  
  15.  
  16.             int n = int.Parse(Console.ReadLine());
  17.             for (int i = 0; i < n; i++)
  18.             {
  19.                 string outerdashes = new string('-', n / 2);
  20.                 if (i == 0)
  21.                 {
  22.                   string firstLineStars1 = new string('*', n + 2);
  23.                     Console.WriteLine(outerdashes + firstLineStars1 + outerdashes);
  24.                 }
  25.                 else
  26.                 {
  27.                     string innerDashes = new string('-', n);
  28.                     Console.WriteLine(outerdashes + "*" + innerDashes + "*" + outerdashes);
  29.                 }
  30.             }
  31.             int equal = 0;
  32.             for (int j = n / 2; j >= 0; j--)
  33.             {
  34.  
  35.  
  36.  
  37.                 string headphoneStars = new string('*', n - 2 * j);
  38.                 string outerDashes = new string('-', (n - (n - 2 * j)) / 2);
  39.                 string innerDashes = new string('-', 1);
  40.  
  41.  
  42.  
  43.  
  44.  
  45.                 Console.WriteLine(outerDashes + headphoneStars + outerDashes + innerDashes + outerDashes + headphoneStars + outerDashes);
  46.  
  47.  
  48.  
  49.             }    
  50.                        
  51.                
  52.             int equal1 = 0;
  53.             for (int p = 1; p < n / 2 + 1; p++)
  54.             {
  55.                 int counter = n - p;
  56.                 if (counter % 2 == 0)
  57.                 {
  58.                     counter--;
  59.                 }
  60.                 if (counter == equal)
  61.                 {
  62.                     counter -= 2;
  63.                }
  64.                 string headphoneStars = new string('*', n - 2  * p);
  65.                    string outerDashes = new string('-', (n - (n - 2 * p)) / 2);
  66.                     string innerDashes = new string('-', 1);
  67.                
  68.                         Console.WriteLine(outerDashes + headphoneStars + outerDashes + innerDashes + outerDashes + headphoneStars + outerDashes);
  69.                        equal1 = counter;
  70.                    
  71.             }
  72.             }
  73.         }
  74.     }
Advertisement
Add Comment
Please, Sign In to add comment