4. uzdevums
Veidoja Ilgvars Līckrastiņš 05.03.2025
Vide: Programiz C# Online Compiler





using System;
using System.Linq;

class Program
{
    static void Main()
    {
        Random rand = new Random();
        string vards = "Ilgvars", uzvards = "Lickrastins";
        char[] vards1 = ("x" + vards).ToCharArray(); // varda simboli
        char[] uzvards1 = ("x" + uzvards).ToCharArray(); // uzvarda simboli
        int uzvardagarums = uzvards1.Length; // uzvarda garums

        string mala = "+---+----+----+----+----+----+----+----+----+----+----+";
        Console.WriteLine(mala);
        Console.WriteLine($"Vards: {vards} ({vards.Length} simboli)"); // izvada vardu un taa garumu
        Console.WriteLine($"Uzvards: {uzvards} ({uzvards.Length} simboli)"); // izvada uzvardu un taa garumu
        Console.Write("| ");
        foreach (char c in vards1)
            Console.Write($"| {c} "); // izvada vardu simbolus
        Console.WriteLine("| max | min | vid | sum |");
        Console.WriteLine(mala);

        for (int i = 0; i < uzvardagarums; i++)
        {
            int[] nums = Enumerable.Range(0, 5).Select(_ => rand.Next(5, 20)).ToArray(); // izveido 5 skaitlus

            Console.Write($"| {uzvards1[i]} ");
            foreach (int n in nums)
                Console.Write($"| {n,2} "); // skaitlu izvade interpoleta veida
            Console.WriteLine($"| {nums.Max(),2} | {nums.Min(),2} | {nums.Average(),4:F1} | {nums.Sum(),3} |");
        }
        Console.WriteLine(mala);
    }
}

