/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 331 - Problem 30: Drawing Isosceles Triangle (a)*/ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static void Main(string[] args) { int n; Console.Write("Please enter a number: "); n = int.Parse(Console.ReadLine()); Console.WriteLine("\n"); //convert the even n to odd if (n % 2 == 0) n++; //upper part for (int i = 0; i < n / 2; i++) Console.Write(" "); Console.Write("*"); Console.Write("\n"); //middle part for (int i = 0; i < n / 2 - 1; i++) { for (int j = 0; j < n / 2 - i - 1; j++) Console.Write(" "); Console.Write("*"); for (int j = 0; j < 2 * i + 1; j++) Console.Write(" "); Console.Write("*"); Console.Write("\n"); } //lower part for (int i = 0; i < n; i++) Console.Write("*"); Console.ReadKey(); } } }