Advertisement
Guest User

telerik carpets

a guest
Jan 24th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2.  
  3. class Carpets
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine()) / 2;
  8.         string slash1 = "";
  9.         string slash2 = "";
  10.         string dots = new string('.', n);
  11.         for (int i = 1; i <= n; i++)
  12.         {
  13.             if (i % 2 == 1)
  14.             {
  15.                 slash1 = slash1 + "/";
  16.                 slash2 = "\\" + slash2;
  17.             }
  18.             else
  19.             {
  20.                 slash1 = slash1 + " ";
  21.                 slash2 = " " + slash2;
  22.             }
  23.  
  24.             dots = dots.Substring(1);
  25.             Console.WriteLine(dots + slash1 + slash2 + dots);
  26.         }
  27.  
  28.         if (n % 2 == 0)
  29.         {
  30.             slash1 = slash1.Substring(1) + slash1[0];
  31.             slash2 = slash2.Substring(1) + slash2[0];
  32.         }
  33.  
  34.         for (int i = n-1; i >= 0; i--)
  35.         {
  36.             Console.WriteLine(dots + slash2 + slash1 + dots);
  37.             dots = dots + ".";
  38.             slash2 = slash2.Remove(i);
  39.             slash1 = slash1.Substring(1);
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement