Advertisement
Yana_Neykova

Untitled

Mar 1st, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  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%2 == 0 )
  19. {
  20. star = "**";
  21. }
  22. string dash = new string ('-', (n- star.Length)/2);
  23.  
  24. Console.WriteLine(dash+star+dash);
  25.  
  26. for (int row = 0; row < upperRows-1; row++)
  27. {
  28. string middleDashes = new string('-',star.Length+row*2);
  29. string sideDashes = new string('-',(n-2-middleDashes.Length)/2);
  30. Console.WriteLine(sideDashes+"*"+middleDashes+"*"+sideDashes);
  31.  
  32. }
  33. int downRows = (n / 2) - n % 2;
  34. for (int lastRows = 1; lastRows < downRows+1; lastRows++)
  35. {
  36. string sideDashes = new string('-', lastRows);
  37. string middleDashes = new string('-', (n - sideDashes.Length* 2)-2);
  38. Console.WriteLine(sideDashes + "*" + middleDashes + "*" + sideDashes);
  39. }
  40. dash = new string('-', (n - star.Length) / 2);
  41.  
  42. Console.WriteLine(dash + star + dash);
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement