Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        public static void NameSurname()
        {
            Console.Write("Lūdzu, ievadiet vārdu un uzvārdu ar atstārpi, vai tikai vārdu: ");
            string nameSurname = Console.ReadLine();

            nameSurname = nameSurname.Trim();
            if (nameSurname.Contains(" "))
            {
                string name    = nameSurname.Substring(0, nameSurname.IndexOf(" ") - 1);
                string surname = nameSurname.Substring(nameSurname.IndexOf(" ") + 1, nameSurname.Length - nameSurname.IndexOf(" ") - 1);
                Task2.PrintNameSurname(name, surname);
                Console.Write("Lūdzu, ievadiet savu vecumu vai nospiediet ENTER: ");
                string age = Console.ReadLine();
                int    ageTrue;
                if (int.TryParse(age, out ageTrue))
                {
                    Task2.PrintNameAge(name, ageTrue);
                }
                else
                {
                    Task2.PrintNameAge(name);
                }
            }
            else
            {
                Task2.PrintNameSurname(nameSurname);
                Console.Write("Lūdzu, ievadiet savu vecumu vai nospiediet ENTER: ");
                string age = Console.ReadLine();
                int    ageTrue;
                if (int.TryParse(age, out ageTrue))
                {
                    Task2.PrintNameAge(nameSurname, ageTrue);
                }
                else
                {
                    Task2.PrintNameAge(nameSurname);
                }
            }
        }
Ejemplo n.º 4
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;
            }
        }