/*
Veidoja: Ralfs Matīss Verņickis
Grupa: 110
Praktiskais darbs: 7
Izmantotais Compiler: Visual Studio
*/
using System;
class Program
{

    static void Main()
    {
        Console.WriteLine("1.uzdevums\n");
        pirmais();
        Console.WriteLine("2.uzdevums\n");
        Noliktava();
        Console.WriteLine("3.uzdevums\n");
        Matematika();
    }

    static void pirmais()
    {
        List<double> izdevumi = new List<double>();
        char izv;
        do
        {
            Console.Write("Ievadi izdevumus: ");
            izdevumi.Add(IevadietIzdevumus());
            Console.WriteLine(izdevumi.Count);
            Console.Write("Turpinat? (j/n): ");
            izv = Convert.ToChar(Console.ReadLine());
        } while (izv != 'n');
        FiltretIzdevumus(izdevumi);
    }

    static List<double> FiltretIzdevumus(List<double> izd)
    {
        Console.WriteLine("Ievadiet minimālo izdevumu vertibu");
        Double min = Convert.ToDouble(Console.ReadLine());
        for (int i = 0; i < izd.Count; i++)
        {
            if (izd[i] < min)
            {
                izd.RemoveAt(i);
                i--;
            }
            else
            {
                Console.WriteLine(izd[i]);
            }
        } return izd;
    }
    static double IevadietIzdevumus()
    {
        Double sk = Convert.ToDouble(Console.ReadLine());
        return sk;
    }

    static void Noliktava()
    {
        string kods;
        string[,] noliktava =
        {
            { "A12", "B83", null,  "C83", "D99" },
            { "X01", null,  null,  "CJ3", "Z77" },
            { null,  "K55", "L90", null,  null  },
            { "M37", "N11", "H21", "T10", "Q05" }
        };
        do
        {
            Console.Write("Ievadi meklējamo preces kodu (x lai apturet): ");
            kods = Console.ReadLine();
            if (kods == "x") break;
            string rezultats = AtklatPreci(noliktava, kods);
            Console.WriteLine(rezultats);

            int tukšie = AprekinatNeaizpilditas(noliktava);
            Console.WriteLine($"Tukšo plauktu skaits: {tukšie}");
        } while (kods != "x");

        static string AtklatPreci(string[,] masivs, string kods)
        {
            bool atrasts = false;
            int eja = -1, plaukts = -1;

            for (int i = 0; i < masivs.GetLength(0); i++)
            {
                for (int j = 0; j < masivs.GetLength(1); j++)
                {
                    if (masivs[i, j] == kods)
                    {
                        eja = i + 1;
                        plaukts = j + 1;
                        atrasts = true;
                        return $"Prece ar kodu {kods} atrasta: Eja {eja}, Plaukts {plaukts}";
                    }
                }
            }
            return $"Prece ar kodu {kods} nav atrasta.";
        }


            static int AprekinatNeaizpilditas(string[,] masivs)
            {
                int skaits = 0;
                for (int i = 0; i < masivs.GetLength(0); i++)
                {
                    for (int j = 0; j < masivs.GetLength(1); j++)
                    {
                        if (masivs[i, j] == null)
                        {
                            skaits++;
                        }
                    }
                }
                return skaits;
            }
    }

        static void Matematika()
        {
            Console.WriteLine("Ievadi x1");
            int x1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Ievadi y1");
            int y1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Ievadi x2");
            int x2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Ievadi y2");
            int y2 = Convert.ToInt32(Console.ReadLine());

            double d = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
            Console.WriteLine($"attalums: {d}");

            Console.WriteLine("\nIevadi lenki grados");
            double gradi = Convert.ToDouble(Console.ReadLine());
            double radiani = gradi * (Math.PI / 180);
            Console.WriteLine($"Radianu vertiba: {radiani}");
        }
    }