using System;

class Program
{
    static void Main()
    {
        //iestatīts mans vards
        string persona = "Kristers Saltais";

        //varda formatesana
        string[] nameparts = persona.ToLower().Split(' ');
        for (int i = 0; i < nameparts.Length; i++)
        {
            if (nameparts[i].Length > 0)
            {
                nameparts[i] = char.ToUpper(nameparts[i][0]) + nameparts[i].Substring(1);
            }
        }
        Console.WriteLine($"Mans vārds: {nameparts[0]}");
        Console.WriteLine($"Mans uzvārds: {string.Join(" ", nameparts, 1, nameparts.Length - 1)}");

        //ievada prasitos datus
        int rindas, kolonas;
        do
        {
            Console.Write("Ievadi rindu skaitu, ne mazāk kā 5: ");
        } while (!int.TryParse(Console.ReadLine(), out rindas) || rindas < 5);

        do
        {
            Console.Write("Ievadi kolonu skaitu, ne mazāk kā 5: ");
        } while (!int.TryParse(Console.ReadLine(), out kolonas) || kolonas < 5);

        //tabulas veidosana un norofmesana
        for (int rinda = 1; rinda <= rindas; rinda++)
        {
            Console.Write("+");
            for (int i = 0; i < Math.Min(rinda, kolonas); i++)
                Console.Write("---+");
            Console.WriteLine();

            //izvada skaitļus un veicina ciparu pariešanu uz sānu
            Console.Write("|");
            int startNum = Math.Max(1, rinda - kolonas + 1); //padara lai sipari aiziet uz sānu
            for (int i = startNum; i < startNum + Math.Min(rinda, kolonas); i++)
                Console.Write($" {i} |");
            Console.WriteLine();
        }

        //tabulas apakšējas rinda izveidošana
        Console.Write("+");
        for (int i = 0; i < Math.Min(rindas, kolonas); i++)
            Console.Write("---+");
        Console.WriteLine();
    }
}
