Advertisement
Svetli0o

Carpets

Apr 3rd, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.07 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 Carpets
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             for (int i = 1; i <= n / 2; i++)
  15.             {
  16.                 string filler = new string('.', n / 2 - i);
  17.                 Console.Write(filler);
  18.                 for (int j = 1; j <= i; j++)
  19.                 {
  20.                     if (j % 2 != 0)
  21.                     {
  22.                         Console.Write("/");
  23.                     }
  24.                     else
  25.                     {
  26.                         Console.Write(" ");
  27.                     }
  28.                 }
  29.                 for (int j = 1; j <= i; j++)
  30.                 {
  31.                     if (i % 2 == 0)
  32.                     {
  33.                         if (j % 2 != 0)
  34.                         {
  35.                             Console.Write(" ");
  36.                         }
  37.                         else
  38.                         {
  39.                             Console.Write("\\");
  40.                         }
  41.                     }
  42.                     else
  43.                     {
  44.                         if (j % 2 != 0)
  45.                         {
  46.                             Console.Write("\\");
  47.                         }
  48.                         else
  49.                         {
  50.                             Console.Write(" ");
  51.                         }
  52.                     }
  53.                 }
  54.  
  55.                 Console.Write(filler);
  56.                 Console.WriteLine();
  57.             }
  58.             //second part
  59.             int counter = 0;
  60.             for (int i = n / 2; i >= 1; i--)
  61.             {
  62.                 string filler = new string('.', counter);
  63.                 Console.Write(filler);
  64.                 for (int j = 1; j <= i; j++)
  65.                 {
  66.                     if (j % 2 != 0)
  67.                     {
  68.                         Console.Write("\\");
  69.                     }
  70.                     else
  71.                     {
  72.                         Console.Write(" ");
  73.                     }
  74.                 }
  75.                 for (int j = 1; j <= i; j++)
  76.                 {
  77.                     if (i % 2 == 0)
  78.                     {
  79.                         if (j % 2 != 0)
  80.                         {
  81.                             Console.Write(" ");
  82.                         }
  83.                         else
  84.                         {
  85.                             Console.Write("/");
  86.                         }
  87.                     }
  88.                     else
  89.                     {
  90.                         if (j % 2 == 0)
  91.                         {
  92.                             Console.Write(" ");
  93.                         }
  94.                         else
  95.                         {
  96.                             Console.Write("/");
  97.                         }
  98.                     }
  99.  
  100.                 }
  101.                 Console.Write(filler);
  102.                 Console.WriteLine();
  103.                 counter++;
  104.             }
  105.         }
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement