Пример #1
0
        public static void Main(string[] args)
        {
            if (uint.TryParse(args[0], out uint input) == false || input == 0)
            {
                ConsoleTools.CloseProgram("Wrong input. Enter the number of elements of Fibbonaci Series (positive number).");
            }

            Console.WriteLine($"Input argument: {String.Join(" ", args)}");

            Console.WriteLine(String.Join("", GetFibbonaciSeries(input)));

            ConsoleTools.CloseProgram();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var robotFactory = new RobotFactory(new JsonDataSource());

            var robot = robotFactory.CreateRobot();

            Console.WriteLine(robot);

            robotFactory.ResetId(robot);

            Console.WriteLine(robot);

            ConsoleTools.CloseProgram();
        }
Пример #3
0
        static void Main(string[] args)
        {
            CreateHand();
            var hands = dataSource.LoadHands();

            var results = GetFulls(hands);

            foreach (var result in results)
            {
                System.Console.WriteLine(result);
            }

            ConsoleTools.CloseProgram();
        }
Пример #4
0
        static void Main(string[] args)
        {
            var documents = new List <IDocument>()
            {
                DocumentFactory.CreateCV("Adam"),
                DocumentFactory.CreateStory("Adam S."),
                DocumentFactory.CreateReport("aaaa")
            };

            foreach (var document in documents)
            {
                document.Print();
            }

            ConsoleTools.CloseProgram();
        }
Пример #5
0
        static void Main(string[] args)
        {
            List <int> input = ConvertInput(args);

            if (input == null || input.Count == 0)
            {
                ConsoleTools.CloseProgram($"Error. Wrong input. (Input: {String.Join(" ", args)})");
            }
            else if (isMoreThanTenDgits(input) == true)
            {
                ConsoleTools.CloseProgram($"Too many digits, result is out of int type size.");
            }
            var sortedFromMax = input.
                                OrderByDescending(p => GetDigitFromLeft(p, 1)).
                                ThenByDescending(p => GetDigitFromLeft(p, 2)).
                                ThenByDescending(p => GetDigitFromLeft(p, 3)).
                                ThenByDescending(p => GetDigitFromLeft(p, 4)).
                                ThenByDescending(p => GetDigitFromLeft(p, 5)).
                                ToList();

            var sortedFromMin = input.
                                OrderBy(p => GetDigitFromLeft(p, 1)).
                                ThenBy(p => GetDigitFromLeft(p, 2)).
                                ThenBy(p => GetDigitFromLeft(p, 3)).
                                ThenBy(p => GetDigitFromLeft(p, 4)).
                                ThenBy(p => GetDigitFromLeft(p, 5)).
                                ToList();

            if (Int32.TryParse(String.Join("", sortedFromMin), out int min) == false)
            {
                ConsoleTools.CloseProgram($"Min number is out of int type size.");
            }

            if (Int32.TryParse(String.Join("", sortedFromMax), out int max) == false)
            {
                int bufor;
                int index         = 0;
                int maxIterations = (sortedFromMax.Count - 1) * (sortedFromMax.Count - 1);
                for (int i = 0; i < maxIterations; i++)
                {
                    if (index == sortedFromMax.Count - 1)
                    {
                        index = 0;
                    }

                    bufor = sortedFromMax[index];
                    sortedFromMax[index]     = sortedFromMax[index + 1];
                    sortedFromMax[index + 1] = bufor;
                    if (Int32.TryParse(String.Join("", sortedFromMax), out max) == true)
                    {
                        break;
                    }
                    index++;
                }
            }

            Console.WriteLine($"Input {String.Join(" ", input)}");
            Console.WriteLine($"Max int: {Int32.MaxValue}");
            Console.WriteLine($"Max {max}");
            Console.WriteLine($"Min {min}");

            ConsoleTools.CloseProgram();
        }