Guest User

Untitled

a guest
Mar 1st, 2017
282
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Diamond
  8. {
  9. class Diamond
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int upperRows = n / 2 + (n % 2); // add 1 or 0 - depending on even/odd
  15. // int firstRow = n / 2;
  16. string star = "*";
  17.  
  18. if (n==1)
  19. {
  20. star = "*";
  21. Console.WriteLine(star);
  22. return;
  23. }
  24. if (n==2)
  25. {
  26. star = "**";
  27. Console.WriteLine(star);
  28. return;
  29. }
  30. string dash = new string('_', (n - star.Length) / 2);
  31.  
  32. Console.WriteLine(dash + star + dash);
  33.  
  34. for (int row = 0; row < upperRows - 1; row++)
  35. {
  36. string middleDashes = new string('_', star.Length + row * 2);
  37. string sideDashes = new string('_', (n - 2 - middleDashes.Length) / 2);
  38. Console.WriteLine(sideDashes + "*" + middleDashes + "*" + sideDashes);
  39.  
  40. }
  41. int downRows = n-(n/2+2);// promenena formula
  42. for (int lastRows = 1; lastRows <= downRows ; lastRows++)
  43. {
  44. string sideDashes = new string('_', lastRows);
  45. string middleDashes = new string('_', (n - sideDashes.Length * 2) - 2);
  46. Console.WriteLine(sideDashes + "*" + middleDashes + "*" + sideDashes);
  47. }
  48. dash = new string('-', (n - star.Length) / 2);
  49.  
  50. Console.WriteLine(dash + star + dash);
  51. }
  52. }
  53. }
RAW Paste Data