Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7. int n = int.Parse(Console.ReadLine());
  8. var leftRight = (n-1)/2;
  9.  
  10. if (n==1)
  11. {
  12. Console.WriteLine("*");
  13. }
  14. else
  15. {
  16.  
  17. for (int i=1; i<=(n-1)/2; i++)
  18. {
  19. //draw up side
  20.  
  21. Console.Write(new String('-',leftRight));
  22. Console.Write("*");
  23. var mid = n-2*leftRight-2;
  24. if (mid >= 0)
  25. {
  26. Console.Write(new String('-',mid));
  27. Console.Write('*');
  28. }
  29.  
  30. Console.WriteLine(new String('-',leftRight));
  31. leftRight --;
  32.  
  33. }
  34.  
  35. //Second Line
  36. Console.WriteLine("*"+new String('-',n-2)+"*");
  37. leftRight++;
  38. for (int i = 0; i<(n-1)/2; i++)
  39. {
  40. Console.Write(new String('-',leftRight));
  41. Console.Write("*");
  42. var mid = n-2*leftRight-2;
  43. if (mid >=0)
  44. {
  45. Console.Write(new String('-',mid));
  46. Console.Write("*");
  47. }
  48. Console.WriteLine(new String('-',leftRight));
  49. leftRight++;
  50. }
  51. }
  52.  
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement