/*
Veidoja: Maksimilians Lukjanskis
Grupa:110
Praktiskais darbs: 5
Izmantotais compiler: https://www.programiz.com/csharp-programming/online-compiler/
*/
using System;

public class HelloWorld
{
    public static void Main()
    {
    pirmais();
    otrais();
    tresais();
    ceturtais();
    piektais();
    }
    public static void pirmais(){
        Console.WriteLine("1 uzd");
        int[,] veseli = { {1,2,3,4}, {5,6,7,8}, {9,10,11,12}};
        
        for(int i = 0; i < veseli.GetLength(0); i++){
            for( int j = 0; j<veseli.GetLength(1); j++){
                Console.Write("\t"+veseli[i,j]);
            }
            Console.WriteLine();
        }
    }
    public static void otrais(){
        Console.WriteLine("2 uzd");
        int[][] skaitli = {
            new int[] {2,1},
            new int[] {5,2,1},
            new int[] {8,2,4,6}
        };
        for(int i =0; i<skaitli.GetLength(0);i++ ){
            for (int j = 0; j<skaitli[i].Length;j++){
                Console.Write("\t"+ skaitli[i][j]);
            }
            Console.WriteLine();
        }
    }
    public static void tresais(){
        Console.WriteLine("3 uzd");
        int[,] summa = {
          {1,3,2,5,6},
          {5,2,5,1,2},
          {8,3,1,3,2},
          {9,7,3,67,3}
        };
        for(int i = 0; i < summa.GetLength(0); i++){
            int sm=0;
            for( int j = 0; j<summa.GetLength(1); j++){
            sm = sm + summa[i, j];
            }
            Console.WriteLine("\t"+(i+1)+" Rindas summa ir "+ sm);
            }
            Console.WriteLine();
    }
    public static void ceturtais(){
        Console.WriteLine("4 uzd");
        int[][] robotais = {
          new int[]{1,6,3},
          new int[]{7,4,2,5},
          new int[]{8,9}
        };
        
        Console.WriteLine("Ievadiet skaitli ko gribat parbaudit!");
        int sk = Convert.ToInt32(Console.ReadLine());
        
        for(int i = 0; i<robotais.Length; i++){ //rinda
            for( int j = 0; j<robotais[i].Length; j++){ //kolona
                if (robotais[i][j] == sk){
                    Console.WriteLine($"Skaitlis {sk} atrodas Rinda:{i+1} Kolona:{j+1} ");
                }
            }
        }
    }
    public static void piektais(){
        Console.WriteLine("5 uzd");
        int[][] robotais2 = {
          new int[]{1,6,3},
          new int[]{7,4,2,5},
          new int[]{8,9}
        };
        for (int i =0; i< robotais2.Length; i++){
            Array.Sort(robotais2[i]);
        }
        Console.WriteLine("\nMasivs pec rindu sakartosanas:");
        for(int i = 0; i< robotais2.Length; i++){
            Console.WriteLine($"[{string.Join(",",robotais2[i])}]");
        }
    }
}