static void Main() { int counter = int.Parse(Console.ReadLine()); Box <int> box = new Box <int>(); for (int i = 0; i < counter; i++) { int input = int.Parse(Console.ReadLine()); box.Values.Add(input); } int[] indexes = Console.ReadLine() .Split() .Select(int.Parse) .ToArray(); int a = indexes[0]; int b = indexes[1]; box.Swap(a, b); Console.WriteLine(box); }
public static void Main() { int count = int.Parse(Console.ReadLine()); Box <int> box = new Box <int>(); for (int i = 0; i < count; i++) { int num = int.Parse(Console.ReadLine()); box.Add(num); } int[] indexes = Console.ReadLine().Split().Select(int.Parse).ToArray(); box.Swap(indexes[0], indexes[1]); Console.WriteLine(box); }
static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List <int> numbers = new List <int>(); for (int i = 0; i < n; i++) { int number = int.Parse(Console.ReadLine()); numbers.Add(number); } Box <int> box = new Box <int>(numbers); int[] indexToSwap = Console.ReadLine() .Split() .Select(int.Parse) .ToArray(); box.Swap(box.Values, indexToSwap[0], indexToSwap[1]); Console.WriteLine(box); }
static void Main(string[] args) { string input; Box <string> box = new Box <string>(); while ((input = Console.ReadLine()) != "END") { string[] tokens = input.Split(); switch (tokens[0]) { case "Add": { box.Add(tokens[1]); break; } case "Remove": { box.Remove(ulong.Parse(tokens[1])); break; } case "Contains": { Console.WriteLine(box.Contains(tokens[1])); break; } case "Swap": { box.Swap(ulong.Parse(tokens[1]), ulong.Parse(tokens[2])); break; } case "Greater": { Console.WriteLine(box.GreaterThan(tokens[1])); break; } case "Max": { Console.WriteLine(box.Max()); break; } case "Min": { Console.WriteLine(box.Min()); break; } case "Print": { Console.Write(box); break; } case "Sort": { box.Sort(); break; } } } }