Beispiel #1
0
        public override string ToString()
        {
            if (RowCount == 1)
            {
                return("*");
            }

            StringBuilder temporary = new StringBuilder();

            for (int i = 0; i < RowCount; i++)
            {
                temporary.Append(Subtask4.Triangle(RowCount, i + 1));
            }
            return(temporary.ToString());
        }
        private static void Main(string[] args)
        {
            int N;

            try
            {
                while (true)
                {
                    Console.Write("Input row count for see image 2, 0 or less number for exit\n N = ");
                    if (int.TryParse(Console.ReadLine(), out N))
                    {
                        if (N > 0)
                        {
                            Subtask4 Tmp = new Subtask4(N);
                            Console.WriteLine(Tmp);
                        }
                        else
                        {
                            Console.Write("Press any key for exit  ");
                            Console.ReadKey();
                            return;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Wrong input! Count must be integer value and more than 0, try again");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "\nPress any key");

                Console.ReadKey();
                return;
            }
        }