/*
Veidoja : Kims Matukevičs
Grupa: 110
Praktiskais darbs 7
Izmantotais Compiler : www.onlinegdb.com
*/
using System;
using System.Collections.Generic;

public class BudzetaAnalize
{
    public static List<double> IevadietIzdevumus()
    {
        List<double> saraksts=new List<double>();
        Console.WriteLine("Ievadiet izdevumus. Beigt – tukša rinda vai 'gals'");
        while(true)
        {
            Console.Write("Ievade: ");
            string ievade=Console.ReadLine();
            if(ievade==""||ievade.ToLower()=="gals") break;
            if(double.TryParse(ievade,out double sk)) saraksts.Add(sk);
            else Console.WriteLine("Tas nav skaitlis");
        }
        return saraksts;
    }
    public static List<double> FiltretIzdevumus(List<double> dati,double slieksnis)
    {
        List<double> rez=new List<double>();
        foreach(double x in dati)
            if(x>=slieksnis) rez.Add(x);
        return rez;
    }
    public static double AprekinatMainibu(List<double> dati)
    {
        if(dati.Count==0) return 0;
        double min=dati[0],max=dati[0];
        foreach(double x in dati)
        {
            if(x<min) min=x;
            if(x>max) max=x;
        }
        return max-min;
    }
}

public class Noliktava
{
    public static string AtklatPreci(string[,] masivs,string kods)
    {
        for(int i=0;i<masivs.GetLength(0);i++)
            for(int j=0;j<masivs.GetLength(1);j++)
                if(masivs[i,j]==kods)
                    return "Prece atrasta Eja "+i+" Plaukts "+j;
        return "Prece nav atrasta";
    }
    public static int AprekinatNeaizpilditas(string[,] masivs)
    {
        int sk=0;
        for(int i=0;i<masivs.GetLength(0);i++)
            for(int j=0;j<masivs.GetLength(1);j++)
                if(masivs[i,j]==""||masivs[i,j]==null) sk++;
        return sk;
    }
}

public class Matem
{
    public static double AprekinatPlaknesAttalumu(double x1,double y1,double x2,double y2)
    {
        double dx=x2-x1,dy=y2-y1;
        return Math.Sqrt(dx*dx+dy*dy);
    }
    public static double KonvertetRadianos(double gradi)
    {
        return gradi*Math.PI/180;
    }
}

public class Program
{
    public static void Main()
    {
        Console.WriteLine("1.UZDEVUMS");
        List<double> iz=BudzetaAnalize.IevadietIzdevumus();
        Console.Write("Slieksnis: ");
        double sl=double.Parse(Console.ReadLine());
        List<double> fil=BudzetaAnalize.FiltretIzdevumus(iz,sl);
        Console.WriteLine("Diapazons: "+BudzetaAnalize.AprekinatMainibu(fil));

        Console.WriteLine("2.UZDEVUMS");
        string[,] nol={{"A1","A2","A3","","A5"},{"B1","B2","","B4","B5"},{"C1","X22","C3","C4","C5"},{"","D2","D3","D4",""}};
        Console.Write("Preces kods: ");
        string kods=Console.ReadLine();
        Console.WriteLine(Noliktava.AtklatPreci(nol,kods));
        Console.WriteLine("Tukši plaukti: "+Noliktava.AprekinatNeaizpilditas(nol));

        Console.WriteLine("3.UZDEVUMS");
        Console.Write("x1: "); double x1=double.Parse(Console.ReadLine());
        Console.Write("y1: "); double y1=double.Parse(Console.ReadLine());
        Console.Write("x2: "); double x2=double.Parse(Console.ReadLine());
        Console.Write("y2: "); double y2=double.Parse(Console.ReadLine());
        Console.WriteLine("Attalums: "+Matem.AprekinatPlaknesAttalumu(x1,y1,x2,y2));
        Console.Write("Lenkis grados: ");
        double gr=double.Parse(Console.ReadLine());
        Console.WriteLine("Radiansi: "+Matem.KonvertetRadianos(gr));
    }
}