GerryM

Carpets

Apr 6th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.99 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Carpets
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int width = int.Parse(Console.ReadLine());
  10.             int center=width/2;
  11.  
  12.             // Upper Right Side
  13.  
  14.             for (int row = 1; row <=center; row++)
  15.             {
  16.                 for (int col = 1; col <=center; col++)
  17.                 {
  18.                     if (col <= center - row)
  19.                     {
  20.                         Console.Write('.');
  21.                     }
  22.                     else
  23.                     {
  24.                         if (center % 2 == 0)
  25.                         {
  26.                             if (((row % 2 != 0) && (col % 2 == 0)) || ((row % 2 == 0) && (col % 2 != 0)))
  27.                             {
  28.                                 Console.Write('/');
  29.  
  30.                             }
  31.                             else if (((row % 2 == 0) && (col % 2 == 0)) || ((row % 2 != 0) && (col % 2 != 0)))
  32.                             {
  33.                                 Console.Write(' ');
  34.                             }
  35.                         }
  36.                         else
  37.                         {
  38.                             if( (row%2!=0 && col%2!=0) || (row%2==0 && col%2==0))
  39.                             {
  40.                                 Console.Write('/');
  41.                             }
  42.                             else if( (row%2==0 && col%2!=0) || (row%2!=0 && col%2==0 ))
  43.                             {
  44.                                 Console.Write(' ');
  45.                             }
  46.                         }
  47.                     }
  48.                    
  49.                 }
  50.  
  51.                //Upper Left Side
  52.  
  53.                 for (int col = center; col>=1; col--)
  54.                 {
  55.                     if (col <= center - row)
  56.                     {
  57.                         Console.Write('.');
  58.                     }
  59.  
  60.                     else
  61.                     {
  62.                         if (center % 2 == 0)
  63.                         {
  64.                             if (((row % 2 != 0) && (col % 2 == 0)) || ((row % 2 == 0) && (col % 2 != 0)))
  65.                             {
  66.                                 Console.Write('\\');
  67.  
  68.                             }
  69.                             else if (((row % 2 == 0) && (col % 2 == 0)) || ((row % 2 != 0) && (col % 2 != 0)))
  70.                             {
  71.                                 Console.Write(' ');
  72.                             }
  73.                         }
  74.                         else
  75.                         {
  76.                             if ((row % 2 != 0 && col % 2 != 0) || (row % 2 == 0 && col % 2 == 0))
  77.                             {
  78.                                 Console.Write('\\');
  79.                             }
  80.                             else if ((row % 2 == 0 && col % 2 != 0) || (row % 2 != 0 && col % 2 == 0))
  81.                             {
  82.                                 Console.Write(' ');
  83.                             }
  84.                         }
  85.                     }
  86.                    
  87.  
  88.                 }
  89.                 Console.WriteLine();
  90.             }
  91.  
  92.             //Down Right Side
  93.  
  94.             for (int row = center; row >0; row--)
  95.             {
  96.                 for (int col = 1; col <= center; col++)
  97.                 {
  98.                     if (col <= center - row)
  99.                     {
  100.                         Console.Write('.');
  101.                     }
  102.                     else
  103.                     {
  104.                         if (center % 2 == 0)
  105.                         {
  106.                             if (((row % 2 != 0) && (col % 2 == 0)) || ((row % 2 == 0) && (col % 2 != 0)))
  107.                             {
  108.                                 Console.Write('\\');
  109.  
  110.                             }
  111.                             else if (((row % 2 == 0) && (col % 2 == 0)) || ((row % 2 != 0) && (col % 2 != 0)))
  112.                             {
  113.                                 Console.Write(' ');
  114.                             }
  115.                         }
  116.                         else
  117.                         {
  118.                             if ((row % 2 != 0 && col % 2 != 0) || (row % 2 == 0 && col % 2 == 0))
  119.                             {
  120.                                 Console.Write('\\');
  121.                             }
  122.                             else if ((row % 2 == 0 && col % 2 != 0) || (row % 2 != 0 && col % 2 == 0))
  123.                             {
  124.                                 Console.Write(' ');
  125.                             }
  126.                         }
  127.                     }
  128.  
  129.                 }
  130.  
  131.                 //Down Left Side
  132.  
  133.                 for (int col = center; col >= 1; col--)
  134.                 {
  135.                     if (col <= center - row)
  136.                     {
  137.                         Console.Write('.');
  138.                     }
  139.  
  140.                     else
  141.                     {
  142.                         if (center % 2 == 0)
  143.                         {
  144.                             if (((row % 2 != 0) && (col % 2 == 0)) || ((row % 2 == 0) && (col % 2 != 0)))
  145.                             {
  146.                                 Console.Write('/');
  147.  
  148.                             }
  149.                             else if (((row % 2 == 0) && (col % 2 == 0)) || ((row % 2 != 0) && (col % 2 != 0)))
  150.                             {
  151.                                 Console.Write(' ');
  152.                             }
  153.                         }
  154.                         else
  155.                         {
  156.                             if ((row % 2 != 0 && col % 2 != 0) || (row % 2 == 0 && col % 2 == 0))
  157.                             {
  158.                                 Console.Write('/');
  159.                             }
  160.                             else if ((row % 2 == 0 && col % 2 != 0) || (row % 2 != 0 && col % 2 == 0))
  161.                             {
  162.                                 Console.Write(' ');
  163.                             }
  164.                         }
  165.                     }
  166.  
  167.  
  168.                 }
  169.                 Console.WriteLine();
  170.             }
  171.         }
  172.     }
  173.  
  174. }
Advertisement
Add Comment
Please, Sign In to add comment