zh_stoqnov

Sandglass

Oct 31st, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using System;
  2.  
  3. namespace SandGlass
  4. {
  5. class SandGlass
  6. {
  7. public static void Main(string[] args)
  8. {
  9. int n = int.Parse(Console.ReadLine());
  10. string dots = new string('.', (n - 1) /2);
  11. int sandClockMiddleI = n / 2;
  12. double nMinusTwo = (n - 2) / 2;
  13. int nMinusTwoDevTwo = (int)Math.Ceiling(nMinusTwo);
  14. for(int i = 0; i < sandClockMiddleI; i++)
  15. {
  16. string stars = new string('*', n - i * 2);
  17. string dot = new string('.', i);
  18. Console.WriteLine(dot + stars + dot);
  19. }
  20. Console.WriteLine(dots + "*" + dots);
  21. for (int i = 0; i <= nMinusTwoDevTwo; i++)
  22. {
  23. string stars2 = new string('*', 2 * i + 3);
  24. string dot2 = new string('.', nMinusTwoDevTwo - i);
  25. Console.WriteLine(dot2 + stars2 + dot2);
  26. }
  27.  
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment