fbinnzhivko

03.01 Dumbbell

May 5th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. class Dumbbell
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.  
  8.         string dumbbellTop = new string('&', n / 2 + 1);
  9.         string emptyTop = new string('.', n / 2);
  10.         string emtpyMiddle = new string('.', n);
  11.         Console.WriteLine(emptyTop + dumbbellTop + emtpyMiddle + dumbbellTop + emptyTop);
  12.  
  13.         for (int i = 0; i < n / 2 - 1; i++)
  14.         {
  15.             string empty = new string('.', n / 2 - i - 1);
  16.             string dumbbell = "&" + new string('*', n / 2 + i) + "&";
  17.             Console.WriteLine(empty + dumbbell + emtpyMiddle + dumbbell + empty);
  18.         }
  19.         //Print middle line
  20.         string bar = new string('=', n);
  21.         string dumbbellCenter = "&" + new string('*', n - 2) + "&";
  22.         Console.WriteLine(dumbbellCenter + bar + dumbbellCenter);
  23.  
  24.         for (int i = n / 2 - 1; i > 0; i--)
  25.         {
  26.             string empty = new string('.', n / 2 - i);
  27.             string dumbbell = "&" + new string('*', n / 2 + i - 1) + "&";
  28.             Console.WriteLine(empty + dumbbell + emtpyMiddle + dumbbell + empty);
  29.         }
  30.         Console.WriteLine(emptyTop + dumbbellTop + emtpyMiddle + dumbbellTop + emptyTop);
  31.     }
  32. }
Add Comment
Please, Sign In to add comment