Example #1
0
 public static void PrintArrayIntOrString()
 {
     int[] arrayInt = new int[] { 1, 2, 3, 4, 5, 6, 10, 8, 9, 10 };
     Task3.PrintArrayValues(arrayInt);
     string[] arrayString = new string[] { "Mani", "sauc", "Artūrs" };
     Task3.PrintArrayValues(arrayString);
 }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Ievadi uzdevuma nr.: ");
            string userInput = Console.ReadLine();
            int    x         = Convert.ToInt32(userInput);

            switch (x)
            {
            case 2:
                Task2.PrintNameSurname("Pārsla Ēberliņa");
                Task2.PrintNameSurname("Pārsla", "Ēberliņa");
                Task2.PrintNameAge("Pārsla", 32);
                Task2.PrintNameAge("Pārsla");
                break;

            case 3:
                int[] array = { 1, 2, 3 };
                Task3.PrintArrayValues(array);
                string[] stringArray = { "a", "b", "c" };
                Task3.PrintArrayValues(stringArray);
                break;

            case 4:
                string[] nameArray = { "Jānis", " ", "Pēteris", "Antons", " ", "Andris" };
                Task3.PrintArrayValues(nameArray);
                nameArray = Task4.GetNonEmtyArray(nameArray);
                Task3.PrintArrayValues(nameArray);
                break;

            case 5:

                //for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(Task5.CalculateSum(1, 2));
                Console.WriteLine(Task5.CalculateSum(2, 3));
                Console.WriteLine(Task5.CalculateSum(3, 3));
            }
            break;

            case 6:
                //Task6();**//
                // break;*/
                //default:
                Console.WriteLine("Ievadi skatli robežās no 2 līdz 6!");
                break;
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Ievadi uzdevuma nr. vai exit, lai iziet no programmas.");
            string taskNr = Console.ReadLine();

            switch (taskNr.Trim())
            {
            case "1":
                TicTacToe.Program.Main(new string[0]);
                break;

            case "2":
                Task2.PrintNameSurname("Kristaps Krūmiņš");
                Task2.PrintNameSurname("Kristaps", "Krūmiņš");
                Task2.PrintNameAge("Kristaps");
                Task2.PrintNameAge("Kristaps", 24);
                break;

            case "3":
                int[]    intArray    = { 1, 3, 5, 2, 7, 13 };
                string[] stringArray = { "a", "Asd" };
                Task3.PrintArrayValues(stringArray);
                Task3.PrintArrayValues(intArray);
                break;

            case "4":
                string[] nameArray = { "Jānis", "   ", "Pēteris", "Antons", "", "Andris" };
                Task3.PrintArrayValues(nameArray);
                nameArray = Task4.GetNonEmptyArray(nameArray);
                Task3.PrintArrayValues(nameArray);
                break;

            case "5":
                Console.WriteLine(Task5.CalculateSum(3, 5));
                Console.WriteLine(Task5.CalculateSum(556, 127));
                Console.WriteLine(Task5.CalculateSum(-13, 17));
                break;

            case "exit":
                return;

            default:
                Console.WriteLine($"Uzdevums '{ taskNr.Trim() }' neeksistē!");
                break;
            }
        }
Example #4
0
        public static void GetNonEmptyArray(string[] array)
        {
            int fillCount = 0;

            foreach (string elem in array)
            {
                fillCount = String.IsNullOrWhiteSpace(elem) ? fillCount : ++fillCount;
            }
            string[] nonEmptyArray = new string[fillCount];
            fillCount = 0;
            for (int i = 0; i < array.Length; i++)
            {
                if (!String.IsNullOrWhiteSpace(array[i]))
                {
                    nonEmptyArray[fillCount++] = array[i];
                }
            }
            Task3.PrintArrayValues(nonEmptyArray);
        }
Example #5
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            bool check = false;

            while (!check)

            {
                Console.Write("Lūdzu. ievadiet veselo skaitļi no 2 līdz 6, vai extra, lai izpildīt attiecīgo uzdevumu \n" +
                              " (exit, lai izietu no programmas): ");
                switch (Console.ReadLine().Trim())
                {
                case "2":
                {
                    Task2.NameSurname();
                    break;
                }

                case "3":
                {
                    Task3.PrintArrayIntOrString();
                    break;
                }

                case "4":
                {
                    string[] arrayString = new string[] { "Jānis", "", "Pēteris", "Antons", "", "Andris" };
                    Task4.GetNonEmptyArray(arrayString);
                    break;
                }

                case "5":

                {
                    Console.WriteLine("x = un y = ");
                    Console.WriteLine(Task5.CalculateSum());
                    int x = 5;
                    int y = x;
                    Console.WriteLine($"x = {x} un y = {y}");
                    Console.WriteLine("x + y = " + Task5.CalculateSum(x, y));
                    x = 3;
                    y = 15;
                    Console.WriteLine($"x = {x} un y = {y}");
                    Console.WriteLine("x + y = " + Task5.CalculateSum(x, y));
                    x = -10;
                    y = 6;
                    Console.WriteLine($"x = {x} un y = {y}");
                    Console.WriteLine("x + y = " + Task5.CalculateSum(x, y));
                    break;
                }

                case "6":
                {
                    Console.Write("Lūdzu, ievadiet Jūsu personas kodu: ");
                    string personId = Console.ReadLine();
                    if (Task6.ValidatePersonId(personId))
                    {
                        Console.WriteLine("Personas koda ir pareizs");
                        Console.Write("Jūsu dzimšanas diena ir ");
                        Task6.PrintBirthday(personId);
                    }
                    else
                    {
                        Console.WriteLine("Personas kods nav pareizs");
                    }
                    break;
                }

                case "extra":
                {
                    break;
                }

                case "exit":
                {
                    check = true;
                    break;
                }

                default:
                {
                    Console.WriteLine("Lūdzu evadiet pareizo ciparu vai vardu!!!");
                    break;
                }
                }
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            Console.Write("Ievadiet uzdevuma nr.: ");
            int taskNr = Convert.ToInt32(Console.ReadLine());

            switch (taskNr)
            {
            case 1:
                TicTacToe.Program.Main(new string[0]);
                break;

            case 2:
                Console.Write("Ievadiet savu vārdu: ");
                string name = Console.ReadLine();
                Console.Write("Ievadiet savu uzvārdu: ");
                string surname = Console.ReadLine();
                Console.Write("Ievadiet savu vecumu: ");
                int age = Convert.ToInt32(Console.ReadLine());

                Task2.PrintNameSurname(name);
                Task2.PrintNameSurname(name, surname);
                Task2.PrintNameAge(name, age);     //age - noklusējuma vērtība ir 99
                break;

            case 3:
                Task3.PrintArrayValues(new int[] { 1, 2, 3, 3, 4, 59, 21, 8 });
                Console.WriteLine("-----");
                Task3.PrintArrayValues(new string[] { "abc", "def", "ghi" });
                break;

            case 4:
                /*string[] array = {"Jānis", "", "Pēteris", "Antons", "", "Andris"};
                 * Task4.PrintArrayValues(array);
                 * Console.WriteLine("-----");
                 * Task4.GetNonEmptyArray(array);*/

                string[] nameArray = { "Jānis", "", "Pēteris", "Antons", "", "Andris" };
                Task3.PrintArrayValues(nameArray);
                nameArray = Task4.GetNonEmptyArray(nameArray);
                Task3.PrintArrayValues(nameArray);
                break;

            case 5:
                Console.WriteLine(Task5.CalculateSum(3, 5));
                Console.WriteLine(Task5.CalculateSum(111, 969));
                Console.WriteLine(Task5.CalculateSum(-7, 11));
                break;

            case 6:
                Task6();
                break;

            case 7:
                Task7();
                break;

            default:
                Console.WriteLine("Such task does not exist!");
                break;
            }
        }