NedyalkoKikov

Diamond

May 2nd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 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()
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int left = n / 2;
  15. int right = left;
  16. if(n % 2 == 0)
  17. {
  18. left--;
  19. }
  20. while(left >= 0)
  21. {
  22. for (int col = 0; col < n; col++)
  23. {
  24. if(col == left || col == right)
  25. {
  26. Console.Write("*");
  27. }
  28. else
  29. {
  30. Console.Write("-");
  31. }
  32. }
  33. left--;
  34. right++;
  35. Console.WriteLine();
  36. }
  37. left = 1;
  38. right = n - 2;
  39. while(left <= right)
  40. {
  41. for (int col = 0; col < n; col++)
  42. {
  43. if(col == left || col == right)
  44. {
  45. Console.Write("*");
  46. }
  47. else
  48. {
  49. Console.Write("-");
  50. }
  51. }
  52. left++;
  53. right--;
  54. Console.WriteLine();
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment