//veidoja: Kaspars Pučinskis
//Grupa: 110
//Praktiskais darbs: 7
//compiler: https://www.programiz.com/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

public class HelloWorld
{
    static bool iziet = false;
    static List<double> saraksts = new List<double>();
    static List<double> izejasDati = new List<double>();
    public static void Main()
    {
        Uzd1();
        Uzd2();
        Uzd3();
    }
    public static void Uzd1()
    {
        Console.Write("Ievadiet izdevumu summu ka decimalskaitli (jaievada vismaz 3 vertibas lai pabeigtu): ");
        while(iziet == false)
        {
            IevadietIzdevumus();
        }
    }
    public static void IevadietIzdevumus()
    {
        double izd = Convert.ToDouble(Console.ReadLine());
        saraksts.Add(izd);
        if (saraksts.Count >=3)
        {
            Console.WriteLine("Lai pabeigtu sarakstu ievadiet tuksumu vai gals, bet ja nevelaties, tad turpiniet rakstit izdevumus!");
            string beigt = Convert.ToString(Console.ReadLine());
            if ((beigt == "gals") || (beigt == ""))
            {
                foreach (double i in saraksts)
                {
                    Console.WriteLine(i);
                }
                iziet = true;
                FiltretIzdevumus();
                AprekinatMainibu();
            }
            else
            {
                iziet = false;
            }
        }
        else
        {
            return;
        }
    }
    public static void FiltretIzdevumus()
    {
        Console.Write("Ievadiet minimalo izdevumu slieksni decimaldala: ");
        double slieksni = Convert.ToDouble(Console.ReadLine());
        foreach (double j in saraksts)
        {
            if (j>slieksni)
            {
                izejasDati.Add(j);
            }
            else 
            {
                continue;
            }
            Console.WriteLine(j);
        }
    }
    public static void AprekinatMainibu()
    {
        double minimalais = Math.Abs(izejasDati.Min());
        double maksimalais = Math.Abs(izejasDati.Max());
        double range = maksimalais - minimalais;
        Console.WriteLine($"Izdevumu diapozons ir {range}.");
    }
    static string [,]  noliktava = 
    {
        {"", "29", "23", "", "22"},
        {"", "27", "", "20", "26"}
    };
    static List<string> NoliktavasSaraksts = new List<string>();
    public static void Uzd2()
    {
        for (int i = 0; i < noliktava.GetLength(0); i++) {
            Console.Write((i+1) + ".Eja:" + "\t");
            for (int j = 0; j < noliktava.GetLength(1); j++) {
            Console.Write((j+1) + ".Plaukts(" + noliktava[i,j] + ")" + "\t");
            }
            Console.WriteLine();
        }
        AtklatPreci(noliktava);
        AprekinatNeaizpilditas();
    }
    public static void AtklatPreci(string[,] args)
    {
        Console.Write("Ievadiet kodu, kuru velaties atrast (20-29): ");
        string kods = Console.ReadLine();
        for (int i = 0; i < noliktava.GetLength(0); i++) {
            for (int j = 0; j < noliktava.GetLength(1); j++) {
            if (kods == noliktava[i,j])
            {
                NoliktavasSaraksts.Add((i+1) + ".Eja " + (j+1) + ".Plaukts " + "Kods:" + noliktava[i,j]);
                break;
            }
            }
        }
    }
    public static void AprekinatNeaizpilditas()
    {
        int Summa = 0;
        for (int i = 0; i < noliktava.GetLength(0); i++) {
            for (int j = 0; j < noliktava.GetLength(1); j++) {
                if ("" == noliktava[i,j] || "null" == noliktava[i,j])
                {
                    Summa=Summa+1;
                }
        }
        }
        Console.WriteLine($"Tuksie plautki noliktava: {Summa}");
    }
    public static void Uzd3()
    {
        AprekinatPlaknesAttalumu();
    }
    public static void AprekinatPlaknesAttalumu()
    {
        Console.WriteLine("3.Uzdevums: Aprekiniet attalumu starp diviem punktiem.");
        Console.WriteLine("Ievadiet x1 un y1: ");
        int x1 = Convert.ToInt32(Console.ReadLine());
        int y1 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Ievadiet x2 un y2: ");
        int x2 = Convert.ToInt32(Console.ReadLine());
        int y2 = Convert.ToInt32(Console.ReadLine());
        int [,] attalums = 
        {
            {x1, y1},
            {x2, y2}
        };
        for (int i = 0; i < attalums.GetLength(0); i++) {
            Console.Write((i+1) + ". Punkta Koordinates: ");
            for (int j = 0; j < attalums.GetLength(1); j++) {
            Console.Write(attalums[i, j] + "\t");
            }
            Console.WriteLine();
        }
        double d = Math.Sqrt(Math.Pow((x2-x1),2)+Math.Pow((y2-y1),2));
        Console.WriteLine($"Attalums: {d}");
        Console.Write("Ievadiet lenka gradus: ");
        double gradi = Convert.ToDouble(Console.ReadLine());
        double radiani = gradi * (Math.PI/180);
        Console.WriteLine($"Radiani: {radiani}");
    }
}