/*
Veidoja: Mikus Tolkačevs
Grupa: 110
Praktiskais darbs 5
Izmantotais compiler: Visual Studio
*/
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    internal class Program
    {
        static void Main()
        {
            Uzdevums1();
            Uzdevums2();
            Uzdevums3();
            Uzdevums4();
            Uzdevums5();
            Uzdevums6();
        }
        public static void Uzdevums1()
        {

            Console.WriteLine("1.Uzdevums");
            int[,] skaitli = {
                { 1,2,3,4 }, {5,6,7,8 },{9,10,11,12}
            };

            for (int e = 0; e < skaitli.GetLength(0); e++)
            {
                Console.Write("Rinda{0}:", 1 + e);
                int sum = 0;
                for (int i = 0; i < skaitli.GetLength(1); i++)

                {
                    sum = sum + skaitli[e, i];
                    Console.Write("\t" + skaitli[e, i]);


                }
                Console.WriteLine();
            }
        }
        public static void Uzdevums2()
        {

            Console.WriteLine("2. Uzdevums");
            int[][] skaitli2 = {
                new int[] { 1, 2 }, new int[] { 6, 7, 8 }, new int[] { 11 }
             };
            for (int j = 0; j < skaitli2.Length; j++)
            {
                Console.Write("rinda " + j + ": ");
                foreach (int num in skaitli2[j])
                    Console.Write(num + " ");

                Console.WriteLine();
            }
        }
        public static void Uzdevums3()
        {
            Console.WriteLine("3. Uzdevums");
            int[,] skaitli3 = {
                { 1,2,3,4,5 }, {6, 7, 8,9,10 },{11,12,13,14,15},{16,17,18,19,20}
            };
            Console.WriteLine("Katras rindas summa");

            for (int r = 0; r < skaitli3.GetLength(0); r++)
            {
                Console.Write("Rinda{0}:", 1 + r);
                int ciparsum = 0;
                for (int v = 0; v < skaitli3.GetLength(1); v++)
                {
                    ciparsum = ciparsum + skaitli3[r, v];
                    Console.Write("\t" + skaitli3[r, v]);
                }



                Console.WriteLine("\tSumma ir " + ciparsum);

            }
        }
        public static void Uzdevums4()
        {
            Console.WriteLine("4. Uzdevums");
            int[][] skaitli4 = {
                new int[] { 11, 2 }, new int[] { 6, 7, 18 }, new int[] { 15 }, new int[] {13, 4, 5, 9, 20}
            };
            for (int x = 0; x < skaitli4.Length; x++)
            {
                Console.Write("rinda " + x + ": ");
                foreach (int num in skaitli4[x])
                    Console.Write(num + " ");

                Console.WriteLine();
            }
            Console.WriteLine("Ievadiet skaitli no 1 lidz 20:");
            string skaitlis = Console.ReadLine();
            if (int.TryParse(skaitlis, out int sk))
            {
                bool skait = false;
                for (int i = 0; i < skaitli4.Length; i++)
                {
                    for (int j = 0; j < skaitli4[i].Length; j++)
                    {
                        if (skaitli4[i][j] == sk)
                        {
                            Console.WriteLine($"Cipars {sk} atrodas [{i}] rinda un [{j}] kolona!");
                            skait = true;
                        }
                    }

                }
                if (!skait)
                    Console.WriteLine("Cipars nav masiva!");
            }
        }
        public static void Uzdevums5()
        {
            Console.WriteLine("5. Uzdevums");
            int[][] skaitli5 = {
                new int[] { 2, 6, 4 },
                new int[] { 8, 7 },
                new int[] { 9, 5, 3, 1 }
            };
            Console.WriteLine(skaitli5.Length);
            for (int i = 0; i < skaitli5.Length; i++)
            {
                Console.Write("\t");
                for (int j = 0; j < skaitli5[i].Length; j++)
                {
                    Console.Write(skaitli5[i][j] + " ");
                }
                Console.WriteLine();

                for (int n = 0; n < skaitli5.Length; n++)
                {

                    Array.Sort(skaitli5[n]);

                }
                Console.WriteLine();

                for (int d = 0; d < skaitli5.Length; d++)
                {
                    Console.Write("\t");
                    for (int j = 0; j < skaitli5[d].Length; j++)
                    {
                        Console.Write(skaitli5[d][j] + " ");
                    }
                    Console.WriteLine();


                }

            }
      
        }
        public static void Uzdevums6()
        {
            Console.WriteLine("6. Uzdevums");
            int[,] skaitli6 = {
                { 1,2,3,4,5 }, {6, 7, 8,9,1 },{1,3,8,2,9}
            };

            for (int i = 0; i < skaitli6.GetLength(1); i++ )
            {
                Console.Write("Rinda{0}:", 1 + i);
                Console.Write("\t");
                for (int j = 0; j < skaitli6.GetLength(0); j++)
                {
                    Console.Write("\t" + skaitli6[j, i]);
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }





    }

        }
    


