Advertisement
TodorovH

IsoscelesTriangle

Mar 12th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. class IsoscelesTriangle
  5. {
  6. static void Main()
  7. {
  8. Console.OutputEncoding = Encoding.GetEncoding("UTF-8");
  9. Console.WriteLine();
  10. Console.WriteLine("This program will print isosceles triangle!");
  11. Console.WriteLine();
  12. Console.Write("Enter number for the base a: ");
  13. int a = int.Parse(Console.ReadLine());
  14. Console.WriteLine();
  15. int b = a + a + 1;
  16. int n = 0;
  17. int c = a + 1;
  18. char emptySpace = ' ';
  19. char symbol = '©';
  20. for (int y = 0; y <= (a - 2); y++, c++)
  21. {
  22. for (n = a - 1; n >= 0; n--)
  23. {
  24. if ((y < (n + 1)) || (y > (n + 1)))
  25. {
  26. Console.Write(emptySpace);
  27. }
  28. else
  29. {
  30. Console.Write(symbol);
  31. }
  32. }
  33. for (int e = a + 1; e <= b; e++)
  34. {
  35. if ((c < e) || (c > e))
  36. {
  37. Console.Write(emptySpace);
  38. }
  39. else
  40. {
  41. Console.Write(symbol);
  42. }
  43. }
  44. Console.WriteLine();
  45. }
  46. for (int x = 1; x <= b; x++) // base of the triangle
  47. {
  48. if (x % 2 == 0)
  49. {
  50. Console.Write(symbol);
  51. }
  52. else
  53. {
  54. Console.Write(emptySpace);
  55. }
  56. }
  57. Console.WriteLine();
  58. Console.WriteLine();
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement