Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int numberOfLines = int.Parse(Console.ReadLine());
- List<Box<int>> boxCollection = new List<Box<int>>();
- for (int i = 0; i < numberOfLines; i++)
- {
- Box<int> boxInt = new Box<int>(int.Parse(Console.ReadLine()));
- boxCollection.Add(boxInt);
- }
- var indexes = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- SwapElements(boxCollection, indexes[0], indexes[1]);
- foreach (var box in boxCollection)
- {
- Console.WriteLine(box);
- }
- }
- private static void SwapElements<T>(List<T> boxCollection, int index1, int index2)
- {
- T tempBox = boxCollection[index1];
- boxCollection[index1] = boxCollection[index2];
- boxCollection[2] = tempBox;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement