/*
Veidoja: Edgars Katajevs
Grupa: 110
Praktiskais darbs: 5
Izmantotais compiler: www.programiz.com
*/

using System;
class Program
{
static void Main()
{
    //PIRMAIS UZDEVUMS
        int[,] dimensijuM = { 
            { 5, 4, 9,67, }, 
            { 3, 50, 8, 69, }, 
            { 4, 8, 16, 21,} 
        };
        
        for (int i = 0; i < dimensijuM.GetLength(0); i++) 
        { 
            for (int j = 0; j < dimensijuM.GetLength(1); j++) 
            { 
                Console.Write(dimensijuM[i, j] + " "); 
            }
            Console.WriteLine();
        }  
    //OTRAIS UZDEVUMS
        Console.WriteLine();
        
        int[][] jagged = new int[3][];
        
        jagged[0] = new int[] { 1, 5, 7, 9 };
        jagged[1] = new int[] { 4, 18 };
        jagged[2] = new int[] { 6, 69, 158, 67, 21 };
        
        for (int i = 0; i < jagged.Length; i++) 
        {
            foreach(int num in jagged[i])
                Console.Write(num + " ");
          
            Console.WriteLine();
        }
    //TRESAIS UZDEVUMS
        Console.WriteLine();
        
        int[,] sum = { 
            { 1, 3, 5, 7, 9 }, 
            { 6, 7, 2, 85, 54 }, 
            { 58, 77, 23, 225, 24 }, 
            { 96, 69, 33, 30, 0 }
        };
        
        int rindas = sum.GetLength(0);
        int colloms = sum.GetLength(1);
        
        for (int i = 0; i < rindas; i++)
        {
            int rinsum = 0;
            for (int j = 0; j < colloms; j++)
            {
                rinsum += sum[i, j];
            }
            Console.WriteLine($"{i + 1}. rindas summa: {rinsum}");
        }
    //CETURTAIS UZDEVUMS
        Console.WriteLine();
        
        int[][] jagged2 = new int[3][];
        
        jagged2[0] = new int[] { 34, 59, 02, 95 };
        jagged2[1] = new int[] { 2, 85, 74 };
        jagged2[2] = new int[] { 1, 152, 52, 48, 67 };
        
        Console.Write("Ievadiet skaitli, ko meklet: ");
        int numb = int.Parse(Console.ReadLine());

        bool atrasts = false;

        for (int i = 0; i < jagged2.Length; i++)
        {
            for (int j = 0; j < jagged2[i].Length; j++)
            {
                if (jagged2[i][j] == numb)
                {
                    Console.WriteLine($"Skaitlis {numb} atrasts {i+1}. rinda, {j+1}. kolonna.");
                    atrasts = true;
                }
            }
        }

        if (!atrasts)
        {
            Console.WriteLine($"Skaitlis {numb} masiva netika atrasts.");
        }
    //PIEKTAIS UZDEVUMS
        Console.WriteLine();
        
        int[][] jagged3 = new int[3][];
        
        jagged3[0] = new int[] { 34, 76, 233, 117 };
        jagged3[1] = new int[] { 40, 95 };
        jagged3[2] = new int[] { 60, 2, 98, 69, 25 };
        
        for (int i = 0; i < jagged3.Length; i++)
        {
            Array.Sort(jagged3[i]);
        }
        
        for (int i = 0; i < jagged3.Length; i++)
        {
            Console.Write($"{i+1}. rinda: ");
            for (int j = 0; j < jagged3[i].Length; j++)
            {
                Console.Write(jagged3[i][j] + " ");
            }
            Console.WriteLine();
        }
        Console.WriteLine();
    }
}
