Advertisement
NikolaySpasovTriset

Diamond

Oct 9th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. int n = int.Parse(Console.ReadLine());
  8. int y = 0;
  9. int z = 0;
  10. int b = 0;
  11. int k = 0;
  12.  
  13. if (n % 2 == 0)
  14. {
  15. for (int i = 0; i < n / 2; i++)
  16. {
  17. Console.Write(new string('-', (n - 2) / 2 - i));
  18. Console.Write("*");
  19. Console.Write(new string('-', z));
  20. Console.Write("*");
  21. Console.WriteLine(new string('-', (n - 2) / 2 - i));
  22.  
  23. z += 2;
  24.  
  25. if (i == (n / 2) - 1)
  26. {
  27. for (int j = 0; j < n / 2 - 1; j++)
  28. {
  29. Console.Write(new string('-', 1 + j));
  30. Console.Write("*");
  31. Console.Write(new string('-', (n - 4) - b));
  32. Console.Write("*");
  33. Console.WriteLine(new string('-', 1 + j));
  34.  
  35. b += 2;
  36. }
  37. }
  38.  
  39. }
  40.  
  41. }
  42. else
  43. {
  44. Console.Write(new string('-', (n / 2)));
  45. Console.Write("*");
  46. Console.WriteLine(new string('-', (n / 2)));
  47.  
  48. for (int i = 0; i < n / 2; i++)
  49. {
  50. Console.Write(new string('-', (n / 2) - (i + 1)));
  51. Console.Write("*");
  52. Console.Write(new string('-', y + 1));
  53. Console.Write("*");
  54. Console.WriteLine(new string('-', (n / 2) - (i + 1)));
  55. y += 2;
  56.  
  57. if (i == (n / 2) - 1)
  58. {
  59. for (int j = 0; j < n / 2 - 1; j++)
  60. {
  61. Console.Write(new string('-', 1 + j));
  62. Console.Write("*");
  63. Console.Write(new string('-', (n - 4) - k));
  64. Console.Write("*");
  65. Console.WriteLine(new string('-', 1 + j));
  66.  
  67. k += 2;
  68. }
  69. Console.Write(new string('-', (n / 2)));
  70. Console.Write("*");
  71. Console.WriteLine(new string('-', (n / 2)));
  72. }
  73.  
  74. }
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement