コード例 #1
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            List <string> list = new List <string>();

            for (int i = 0; i < n; i++)
            {
                string input = Console.ReadLine();

                list.Add(input);
            }

            int[] indexes = Console.ReadLine()
                            .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                            .Select(int.Parse)
                            .ToArray();
            int firstIndex  = indexes[0];
            int secondIndex = indexes[1];


            Box <string> box = new Box <string>(list);

            box.Swap(list, firstIndex, secondIndex);

            Console.WriteLine(box);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Box <int> box = new Box <int>();

            for (int i = 0; i < n; i++)
            {
                int line = int.Parse(Console.ReadLine());

                box.Add(line);
            }

            int[] input = Console.ReadLine()
                          .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                          .Select(int.Parse)
                          .ToArray();

            int firstIndex  = input[0];
            int secondIndex = input[1];

            box.Swap(firstIndex, secondIndex);

            Console.WriteLine(box);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            int          n     = int.Parse(Console.ReadLine());
            Box <string> boxes = new Box <string>();

            for (int i = 0; i < n; i++)
            {
                string item = Console.ReadLine();

                boxes.AddBox(item);
            }

            int[] indexes = Console.ReadLine().Split().Select(int.Parse).ToArray();
            boxes.Swap(indexes[0], indexes[1]);

            Console.WriteLine(boxes);
        }
コード例 #4
0
        public static void Main(string[] args)
        {
            int           n        = int.Parse(Console.ReadLine());
            List <string> messages = new List <string>();

            for (int i = 0; i < n; i++)
            {
                string message = Console.ReadLine();
                messages.Add(message);
            }
            int[] indexes = Console.ReadLine().Split().Select(int.Parse).ToArray();


            Box <string> box = new Box <string>(messages);

            box.Swap(indexes[0], indexes[1]);

            Console.WriteLine(box);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            int n   = int.Parse(Console.ReadLine());
            var box = new Box <string>();

            for (int i = 0; i < n; i++)
            {
                string input = Console.ReadLine();

                box.Add(input);
            }

            int[] indexes = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int   x       = indexes[0];
            int   y       = indexes[1];

            box.Swap(x, y);

            box.Printer();
        }
コード例 #6
0
        public static void Main(string[] args)
        {
            int           n        = int.Parse(Console.ReadLine());
            List <string> elements = new List <string>();

            for (int i = 0; i < n; i++)
            {
                string currentelement = Console.ReadLine();
                elements.Add(currentelement);
            }
            int[] indexes     = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
            int   firstIndex  = indexes[0];
            int   secondIndex = indexes[1];

            Box <string> box = new Box <string>(elements);

            box.Swap(firstIndex, secondIndex);

            Console.Write(box.ToString());
        }
コード例 #7
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Box <int> box = new Box <int>();

            for (int i = 0; i < n; i++)
            {
                var input = int.Parse(Console.ReadLine());
                box.MyList.Add(input);
            }
            var indexes = Console.ReadLine()
                          .Split(' ', StringSplitOptions.RemoveEmptyEntries)
                          .Select(int.Parse)
                          .ToArray();

            box.Swap(indexes[0], indexes[1]);

            Console.WriteLine(box);
        }
コード例 #8
0
        static void Main(string[] args)
        {
            int           n      = int.Parse(Console.ReadLine());
            List <string> values = new List <string>();

            for (int i = 0; i < n; i++)
            {
                string value = Console.ReadLine();
                values.Add(value);
            }

            int[] indexes     = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int   firstIndex  = indexes[0];
            int   secondIndex = indexes[1];

            Box <string> box = new Box <string>(values);

            box.Swap(firstIndex, secondIndex);
            Console.WriteLine(box);
        }
コード例 #9
0
        public static void Main()
        {
            int numberOfBoxes = int.Parse(Console.ReadLine());

            Box <string> box = new Box <string>();

            for (int i = 0; i < numberOfBoxes; i++)
            {
                string input = Console.ReadLine();
                box.Values.Add(input);
            }

            int[] indexes = Console.ReadLine()
                            .Split()
                            .Select(int.Parse)
                            .ToArray();

            box.Swap(indexes[0], indexes[1]);

            Console.WriteLine(box);
        }
コード例 #10
0
        static void Main()
        {
            Box <string> box        = new Box <string>();
            int          countItems = int.Parse(Console.ReadLine());

            for (int i = 0; i < countItems; i++)
            {
                box.Add(Console.ReadLine());
            }

            int[] inputIndexes = Console.ReadLine()
                                 .Split(' ', StringSplitOptions.RemoveEmptyEntries)
                                 .Select(int.Parse)
                                 .ToArray();

            int firstIndex  = inputIndexes[0];
            int secondIndex = inputIndexes[1];

            box.Swap(firstIndex, secondIndex);

            Console.WriteLine(box.ToString());
        }
コード例 #11
0
        public static void Main(string[] args)
        {
            var counter = int.Parse(Console.ReadLine());

            var box = new Box <int>();

            for (int i = 0; i < counter; i++)
            {
                var input = int.Parse(Console.ReadLine());

                box.Values.Add(input);
            }

            var swapIndexes = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var firstIndex  = swapIndexes[0];
            var secondIndex = swapIndexes[1];

            box.Swap(firstIndex, secondIndex);

            Console.WriteLine(box);
        }
コード例 #12
0
        static void Main(string[] args)
        {
            Box <string> box        = new Box <string>();
            int          countLines = int.Parse(Console.ReadLine());

            for (int i = 0; i < countLines; i++)
            {
                string input = Console.ReadLine();

                box.Add(input);
            }

            int[] indexes = Console.ReadLine()
                            .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                            .Select(int.Parse)
                            .ToArray();
            box.Swap(indexes[0], indexes[1]);

            string result = box.ToString();

            Console.WriteLine(result);
        }
コード例 #13
0
        static void Main(string[] args)
        {
            List <string> input = new List <string>();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                input.Add(Console.ReadLine());
            }

            Box <string> box = new Box <string>(input);

            int[] swapIndexes = Console.ReadLine()
                                .Split()
                                .Select(int.Parse)
                                .ToArray();

            box.Swap(box.Values, swapIndexes[0], swapIndexes[1]);

            Console.WriteLine(box);
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: VenziVi/SoftUni
        static void Main(string[] args)
        {
            int           n    = int.Parse(Console.ReadLine());
            List <string> list = new List <string>();
            Box <string>  box  = new Box <string>();

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine();
                list.Add(input);
            }

            int[] splited     = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int   firstIndex  = splited[0];
            int   secondIndex = splited[1];

            box.Swap(list, firstIndex, secondIndex);

            foreach (var item in list)
            {
                Console.WriteLine($"{item.GetType()}: {item}");
            }
        }
コード例 #15
0
        static void Main(string[] args)
        {
            var inputCount = int.Parse(Console.ReadLine());
            var boxes      = new List <Box <string> >();

            for (int i = 0; i < inputCount; i++)
            {
                var input  = Console.ReadLine();
                var curBox = new Box <string>(input);
                boxes.Add(curBox);
            }

            var indiceInput = Console.ReadLine()
                              .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                              .Select(int.Parse)
                              .ToArray();

            Box <string> .Swap(indiceInput, boxes);

            foreach (var box in boxes)
            {
                Console.WriteLine(box);
            }
        }
コード例 #16
0
        public static void Main(string[] args)
        {
            List <string> lines = new List <string>();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string line = Console.ReadLine();
                lines.Add(line);
            }
            Box <string> box = new Box <string>(lines);

            int [] indexesToSwap = Console.ReadLine()
                                   .Split()
                                   .Select(int.Parse)
                                   .ToArray();
            int firstIndex  = indexesToSwap[0];
            int secondIndex = indexesToSwap[1];

            box.Swap(firstIndex, secondIndex);

            Console.WriteLine(box);
        }