Advertisement
Guest User

4-Persian-Rugs

a guest
Feb 4th, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. int N = int.Parse(Console.ReadLine());
  8. int D = int.Parse(Console.ReadLine());
  9.  
  10.  
  11.  
  12. // WITHOUT TRIANGLES
  13. if (N <= D)
  14. {
  15. // upper part
  16. for (int i = 0; i < N; i++)
  17. {
  18. int spacesUp = N * 2 - 1;
  19. Console.Write(new string('#', i));
  20. Console.Write(new string('\\', 1));
  21. Console.Write(new string(' ', spacesUp));
  22. Console.Write(new string('/', 1));
  23. Console.WriteLine(new string('#', i));
  24. spacesUp -= 2;
  25. }
  26.  
  27. // midline
  28. Console.Write(new string('#', N));
  29. Console.Write(new string('X', 1));
  30. Console.WriteLine(new string('#', N));
  31.  
  32. // lower part
  33. int spacesDown = 1;
  34. for (int i = 0; i < N; i++)
  35. {
  36. Console.Write(new string('#', N - 1 - i));
  37. Console.Write(new string('/', 1));
  38. Console.Write(new string(' ', spacesDown));
  39. Console.Write(new string('\\', 1));
  40. Console.WriteLine(new string('#', N - 1 - i));
  41. spacesDown += 2;
  42. }
  43. }
  44. // WITH TRIANGLES
  45. else if (N > D) // N = 5; D = 2
  46. {
  47. int countSpaces = D;
  48. // upper triangle
  49. for (int i = 1; i <= N - D - 1; i++)
  50. {
  51. countSpaces = D;
  52.  
  53. int dots = 2 * N - 2 * countSpaces - 3 - 2 * (i - 1);
  54. Console.Write(new string('#', i - 1)); //
  55. Console.Write(new string('\\', 1)); //
  56. Console.Write(new string(' ', countSpaces)); //
  57.  
  58. Console.Write(new string('\\', 1)); //
  59.  
  60. Console.Write(new string('.', dots));
  61. Console.Write(new string('/', 1)); //
  62.  
  63. Console.Write(new string(' ', countSpaces)); //
  64. Console.Write(new string('/', 1)); //
  65. Console.WriteLine(new string('#', i - 1)); //
  66. }
  67. // upper mid part
  68. for (int j = N - D; j <= N; j++)
  69. {
  70. int midSpaces = 2 * N - 2 * j + 1;
  71. Console.Write(new string('#', j - 1));
  72. Console.Write(new string('\\', 1));
  73. Console.Write(new string(' ', midSpaces));
  74. Console.Write(new string('/', 1));
  75. Console.WriteLine(new string('#', j - 1));
  76.  
  77. }
  78. // midline
  79. Console.Write(new string('#', N));
  80. Console.Write(new string('X', 1));
  81. Console.WriteLine(new string('#', N));
  82.  
  83. // lower mid part
  84. for (int j = N; j >= N - D; j--)
  85. {
  86. int midSpaces = 2 * N - 2 * j + 1;
  87. Console.Write(new string('#', j - 1));
  88. Console.Write(new string('/', 1));
  89. Console.Write(new string(' ', midSpaces));
  90. Console.Write(new string('\\', 1));
  91. Console.WriteLine(new string('#', j - 1));
  92. }
  93.  
  94. // lower triangle
  95. for (int i = N - D - 1; i >= 1; i--)
  96. {
  97. countSpaces = D;
  98.  
  99. int dots = 2 * N - 2 * countSpaces - 3 - 2 * (i - 1);
  100. Console.Write(new string('#', i - 1)); //
  101. Console.Write(new string('/', 1)); //
  102. Console.Write(new string(' ', countSpaces)); //
  103.  
  104. Console.Write(new string('/', 1)); //
  105.  
  106. Console.Write(new string('.', dots));
  107. Console.Write(new string('\\', 1)); //
  108.  
  109. Console.Write(new string(' ', countSpaces)); //
  110. Console.Write(new string('\\', 1)); //
  111. Console.WriteLine(new string('#', i - 1)); //
  112. }
  113.  
  114. }
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement