Advertisement
Guest User

Explorer

a guest
Nov 21st, 2014
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. int n = int.Parse(Console.ReadLine());
  8. Console.WriteLine("{0}{1}{0}", new string('-', n / 2), '*');
  9. //Upper part and middle;
  10. int outerDots = n / 2 - 1;
  11. int innerDots = 1;
  12. for (int i = 0; i < n / 2; i++)
  13. {
  14. Console.WriteLine("{0}{1}{2}{1}{0}", new string('-', outerDots),
  15. '*', new string('-', innerDots));
  16. outerDots--;
  17. innerDots += 2;
  18. }
  19. //Lower part;
  20. outerDots = 1;
  21. innerDots = n - 4; //The middle line is n - 2 (2 stars) and the next under it
  22. // is n - 4;
  23. for (int i = 0; i < n / 2 - 1; i++)// -1, since the middle is done;
  24. {
  25. Console.WriteLine("{0}{1}{2}{1}{0}", new string('-', outerDots),
  26. '*', new string('-', innerDots));
  27. outerDots++;
  28. innerDots -= 2;
  29. }
  30. Console.WriteLine("{0}{1}{0}", new string('-', n / 2), '*');
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement