Advertisement
Guest User

Untitled

a guest
Feb 5th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.71 KB | None | 0 0
  1. using System;
  2. class PersianRugs
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.         int d = int.Parse(Console.ReadLine());
  8.         int dimention = 2 * n + 1;
  9.         int startslash = 0;
  10.         int endslash = n;
  11.         int startTri = 1 + d;
  12.         int endTri = n;
  13.  
  14.         int[,] matrix = new int[dimention, dimention];
  15.  
  16.         for (int row = 0; row < dimention / 2; row++)
  17.         {
  18.             for (int col = 0; col < dimention / 2; col++)
  19.             {
  20.                 if (startslash <= col && endslash >= col)
  21.                 {
  22.                     if (d < n - 2 && col > startTri && col <= endTri)
  23.                     {
  24.                         matrix[row, col] = 4;
  25.                         matrix[dimention - 1 - row, col] = 4;
  26.                         matrix[row, dimention - 1 - col] = 4;
  27.                         matrix[dimention - 1 - row, dimention - 1 - col] = 4;
  28.                     }
  29.                     else
  30.                         if (d <= n - 2 && col >= startTri && col <= endTri)
  31.                         {
  32.                             matrix[row, col] = 2;
  33.                             matrix[dimention - 1 - row, col] = 3;
  34.                             matrix[row, dimention - 1 - col] = 3;
  35.                             matrix[dimention - 1 - row, dimention - 1 - col] = 2;
  36.  
  37.                         }
  38.                         else
  39.                             if (startslash + 1 <= col && endslash >= col)
  40.                             {
  41.                                 matrix[row, col] = 1;
  42.                                 matrix[dimention - 1 - row, col] = 1;
  43.                                 matrix[row, dimention - 1 - col] = 1;
  44.                                 matrix[dimention - 1 - row, dimention - 1 - col] = 1;
  45.                             }
  46.                             else
  47.                             {
  48.                                 matrix[row, col] = 2;
  49.                                 matrix[dimention - 1 - row, col] = 3;
  50.                                 matrix[row, dimention - 1 - col] = 3;
  51.                                 matrix[dimention - 1 - row, dimention - 1 - col] = 2;
  52.                             }
  53.                 }
  54.             }
  55.             startslash++;
  56.             startTri++;
  57.         }
  58.  
  59.         for (int row = 0; row < dimention; row++)
  60.         {
  61.             int col = n;
  62.             matrix[row, col] = 1;
  63.             matrix[n, col] = 5;
  64.         }
  65.  
  66.         for (int row = 0; row < dimention; row++)
  67.         {
  68.             int col = n;
  69.             if (n - d - 1>= row && ((matrix[row, n - 1] == 2 && matrix[row, n-2] != 0) || matrix[row, n-1] == 4))
  70.             {
  71.                 matrix[row, col] = 4;
  72.                 matrix[dimention - 1 - row, col] = 4;
  73.             }
  74.         }
  75.        
  76.  
  77.         for (int row = 0; row < dimention; row++)
  78.         {
  79.             for (int col = 0; col < dimention; col++)
  80.             {
  81.                 if (matrix[row, col] == 0)
  82.                 {
  83.                     Console.Write('#');
  84.                 }
  85.                 else if (matrix[row, col] == 1)
  86.                 {
  87.                     Console.Write(' ');
  88.                 }
  89.                 else if (matrix[row, col] == 2)
  90.                 {
  91.                     Console.Write('\\');
  92.                 }
  93.                 else if (matrix[row, col] == 3)
  94.                 {
  95.                     Console.Write('/');
  96.                 }
  97.                 else if (matrix[row, col] == 4)
  98.                 {
  99.                     Console.Write('.');
  100.                 }
  101.                 else if (matrix[row, col] == 5)
  102.                 {
  103.                     Console.Write('X');
  104.                 }
  105.             }
  106.             Console.WriteLine();
  107.         }
  108.  
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement