SHARE
TWEET

4. Persian rugs

a guest Feb 4th, 2015 150 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8.  
  9. class Program
  10. {
  11.     static void Main()
  12.     {
  13.         Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  14.  
  15.         int n = int.Parse(Console.ReadLine());
  16.         int k = int.Parse(Console.ReadLine());
  17.  
  18.         int width = 2*n + 1;
  19.  
  20.         for (int i = 0; i < n; i++)
  21.         {
  22.             Console.Write(new string('#', i));
  23.             Console.Write("\\");
  24.             if (width > 2 * i + 2 * k + 4)
  25.             {
  26.                 Console.Write(new string(' ', k));
  27.                 Console.Write("\\");
  28.                 Console.Write(new string('.', width - 2*k - 4 - 2*i));
  29.                 Console.Write("/");
  30.                 Console.Write(new string(' ', k));
  31.             }
  32.             else
  33.             {
  34.                 Console.Write(new string(' ', width - 2 - 2*i));
  35.             }
  36.             Console.Write("/");
  37.             Console.WriteLine(new string('#', i));
  38.         }
  39.         Console.Write(new string('#', n));
  40.         Console.Write("X");
  41.         Console.WriteLine(new string('#', n));
  42.         for (int i = n - 1; i >= 0; i--)
  43.         {
  44.             Console.Write(new string('#', i));
  45.             Console.Write("/");
  46.             if (width > 2 * i + 2 * k + 4)
  47.             {
  48.                 Console.Write(new string(' ', k));
  49.                 Console.Write("/");
  50.                 Console.Write(new string('.', width - 2 * k - 4 - 2 * i));
  51.                 Console.Write("\\");
  52.                 Console.Write(new string(' ', k));
  53.             }
  54.             else
  55.             {
  56.                 Console.Write(new string(' ', width - 2 - 2 * i));
  57.             }
  58.             Console.Write("\\");
  59.             Console.WriteLine(new string('#', i));
  60.         }
  61.     }
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top