/*
Izveidoja : Roberts Dorbe
Grupa : 110
Praktiskais darbs 5
Izmantotais compiler : onlinegdb
*/
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("1.uzd.");
        int[,] masivs1 = {
            { 1, 2, 3, 4 },
            { 5, 6, 7, 8 },
            { 9, 10, 11, 12 }
        };
        for (int i = 0; i < masivs1.GetLength(0); i++)
        {
            for (int j = 0; j < masivs1.GetLength(1); j++)
            {
                Console.Write(masivs1[i, j] + "\t");
            }
            Console.WriteLine();
        }

        Console.WriteLine("2.uzd");
        int[][] robotais1 = new int[3][];
        robotais1[0] = new int[] { 1, 2 };
        robotais1[1] = new int[] { 3, 4, 5 };
        robotais1[2] = new int[] { 6 };
        for (int i = 0; i < robotais1.Length; i++)
        {
            for (int j = 0; j < robotais1[i].Length; j++)
            {
                Console.Write(robotais1[i][j] + "\t");
            }
            Console.WriteLine();
        }

        Console.WriteLine("3.uzd.");
        int[,] masivs2 = {
            { 1, 2, 3, 4, 5 },
            { 6, 7, 8, 9, 10 },
            { 11, 12, 13, 14, 15 },
            { 16, 17, 18, 19, 20 }
        };
        for (int i = 0; i < masivs2.GetLength(0); i++)
        {
            int summa = 0;
            for (int j = 0; j < masivs2.GetLength(1); j++)
            {
                summa += masivs2[i, j];
            }
            Console.WriteLine(summa);
        }

        Console.WriteLine("4.uzd.");
        int[][] robotais2 = {
            new int[] { 3, 7, 1 },
            new int[] { 9, 4, 2, 6 },
            new int[] { 8, 5 }
        };
        Console.Write("Ievadiet skaitli: ");
        int meklejamais = int.Parse(Console.ReadLine());
        bool atrasts = false;
        for (int i = 0; i < robotais2.Length; i++)
        {
            for (int j = 0; j < robotais2[i].Length; j++)
            {
                if (robotais2[i][j] == meklejamais)
                {
                    Console.WriteLine($"Atrasts rindā {i}, kolonnā {j}");
                    atrasts = true;
                }
            }
        }
        if (!atrasts) Console.WriteLine("Nav atrasts");

        Console.WriteLine("5.uzd");
        int[][] robotais3 = {
            new int[] { 5, 2, 9 },
            new int[] { 7, 1 },
            new int[] { 4, 3, 8, 6 }
        };
        for (int i = 0; i < robotais3.Length; i++)
        {
            Array.Sort(robotais3[i]);
        }
        for (int i = 0; i < robotais3.Length; i++)
        {
            for (int j = 0; j < robotais3[i].Length; j++)
            {
                Console.Write(robotais3[i][j] + "\t");
            }
            Console.WriteLine();
        }
    }
}
