Advertisement
Guest User

Diamond

a guest
Jul 17th, 2016
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 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 Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int LeftRight = (n - 1) / 2;
  15. int stars = 1;
  16. if (n%2==0)
  17. {
  18. stars++;
  19. }
  20. for (int i = 1; i <= (n - 1) / 2; i++)
  21. {
  22. Console.Write(new string('-', LeftRight));
  23. Console.Write("*");
  24. int mid = n - 2 * LeftRight - 2;
  25. if (mid >= 0)
  26. {
  27. Console.Write(new string('-', mid));
  28. Console.Write("*");
  29. }
  30. Console.WriteLine(new string('-', LeftRight));
  31. LeftRight--;
  32. }
  33.  
  34. for (int y = 1; y <= (n - 1) / 2; y++)
  35. {
  36. Console.Write(new string('-', LeftRight));
  37. Console.Write("*");
  38. int mid = n - 2 * LeftRight - 2;
  39. if (mid >= 0)
  40. {
  41. Console.Write(new string('-', mid));
  42. Console.Write("*");
  43. }
  44.  
  45. Console.WriteLine(new string('-', LeftRight));
  46. LeftRight++;
  47. }
  48. Console.Write(new string('-', LeftRight));
  49. Console.Write(new string('*', stars));
  50. Console.WriteLine(new string('-', LeftRight));
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement