/*
Veidoja: Ralfs Matīss Verņickis
Grupa: 110
Praktiskais darbs: 5
Izmantotais Compiler: Visual Studio
*/
using System;
class Program
{
    static void Main()
    {
        Console.WriteLine("1. uzdevums");
        uzdevums1();
        Console.WriteLine("\n2. uzdevums");
        uzdevums2();
        Console.WriteLine("\n3. uzdevums");
        uzdevums3();
        Console.WriteLine("\n4. uzdevums");
        uzdevums4();
        Console.WriteLine("\n5. uzdevums");
        uzdevums5();

    }
    static void uzdevums1()
    {
        int[,] masivs1 =
        {
            {1, 2, 3, 4},
            {10, 20, 30, 40},
            {-5, 0, 7, 99}

        };

        for (int i = 0; i < masivs1.GetLength(0); i++)
        {
            for (int j = 0; j < masivs1.GetLength(1); j++)
            {
                Console.Write($"{masivs1[i, j],4}");
            }
            Console.WriteLine();
        }
    }



    static void uzdevums2()
    {
        int[][] Labubu1 = new int[3][];
        Labubu1[0] = new int[] { 1, 2 };
        Labubu1[1] = new int[] { 5, 12, 8 };
        Labubu1[2] = new int[] { -2 };
        for (int i = 0; i < Labubu1.Length; i++)
        {
            for (int j = 0; j < Labubu1[i].Length; j++)
            {
                Console.Write(Labubu1[i][j] + "\t");
            }
            Console.WriteLine();
        }

    }

    static void uzdevums3()
    {
        int[,] Masivs1 = {
            { 1, 2, 3, 4, 5 },
            { 12, 4, 9, 7, 4 },
            { -11, 90, -77, 26, -13 },
            { -5, -5, -9, -16, -11 }
        };
        for (int i = 0; i < Masivs1.GetLength(0); i++)
        {
            int summa = 0;
            for (int j = 0; j < Masivs1.GetLength(1); j++)
            {
                summa += Masivs1[i, j];
            }
            Console.WriteLine(summa);
        }
        Console.WriteLine();
    }


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


    static void uzdevums5()
    {
        int[][] Rob1 = {
            new int[] { 2, 9, 8 },
            new int[] { 65, 7, -3 },
            new int[] { 9, 67, 12, 3 }
        };

        for (int i = 0; i < Rob1.Length; i++)
        {
            Array.Sort(Rob1[i]);
        }
        for (int i = 0; i < Rob1.Length; i++)
        {
            for (int j = 0; j < Rob1[i].Length; j++)
            {
                Console.Write(Rob1[i][j] + "\t");
            }
            Console.WriteLine();
        }
    }
}