/*
    Veidoja: Roberts Onzuls
    Grupa: 110
    Praktiskais darbs 5
    Izmantotais Compiler: www.programiz.com
*/
using System;

class Program
{
static void Main()
{
        int[,] masivs = { 
            { 1, 4, 2, 67 }, 
            { 3, 6, 8, 12 }, 
            { 54, 7, 9, 21 } 
        };
        
        for (int i = 0; i < masivs.GetLength(0); i++) 
        { 
            for (int j = 0; j < masivs.GetLength(1); j++) 
            { 
                Console.Write(masivs[i, j] + " "); 
            }
            Console.WriteLine();
        }  
        
        Console.WriteLine();
        
        int[][] robs1 = new int[3][];
        
        robs1[0] = new int[] { 1, 2, 3, 7 };
        robs1[1] = new int[] { 4, 12 };
        robs1[2] = new int[] { 6, 54, 18, 67, 5 };
        
        for (int i = 0; i < robs1.Length; i++) 
        {
            foreach(int num in robs1[i])
                Console.Write(num + " ");
          
            Console.WriteLine();
        }
        
        Console.WriteLine();
        
        int[,] summa = { 
            { 1, 12, 2, 84, 22 }, 
            { 3, 9, 28, 45, 11 }, 
            { 54, 73, 19, 21, 23 }, 
            { 31, 41, 71, 33, 0 }
        };
        
        int rindas = summa.GetLength(0);
        int kolonnas = summa.GetLength(1);
        
        for (int i = 0; i < rindas; i++)
        {
            int rinsum = 0;
            for (int j = 0; j < kolonnas; j++)
            {
                rinsum += summa[i, j];
            }
            Console.WriteLine($"{i + 1}. rindas summa: {rinsum}");
        }
        
        Console.WriteLine();
        
        int[][] robs2 = new int[3][];
        
        robs2[0] = new int[] { 34, 82, 23, 117 };
        robs2[1] = new int[] { 4, 12, 32 };
        robs2[2] = new int[] { 6, 54, 18, 67, 5 };
        
        Console.Write("Ievadiet skaitli, ko meklet: ");
        int skaitlis = int.Parse(Console.ReadLine());

        bool atrasts = false;

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

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