Ejemplo n.º 1
0
    public static void Main()
    {
        var mycollection  = Console.ReadLine().Split();
        var addColl       = new AddCollection <string>();
        var addRemoveColl = new AddRemoveColection <string>();
        var mylist        = new MyList <string>();

        var sb = new StringBuilder();

        foreach (var element in mycollection)
        {
            sb.Append($"{addColl.Add(element)} ");
        }
        Console.WriteLine(sb.ToString().Trim());

        sb.Clear();
        foreach (var element in mycollection)
        {
            sb.Append($"{addRemoveColl.Add(element)} ");
        }
        Console.WriteLine(sb.ToString().Trim());

        sb.Clear();
        foreach (var element in mycollection)
        {
            sb.Append($"{mylist.Add(element)} ");
        }
        Console.WriteLine(sb.ToString().Trim());

        var numberOfRemove = int.Parse(Console.ReadLine());

        sb.Clear();
        for (int i = 0; i < numberOfRemove; i++)
        {
            sb.Append($"{addRemoveColl.Remove()} ");
        }
        Console.WriteLine(sb.ToString().Trim());

        sb.Clear();
        for (int i = 0; i < numberOfRemove; i++)
        {
            sb.Append($"{mylist.Remove()} ");
        }
        Console.WriteLine(sb.ToString().Trim());
    }
Ejemplo n.º 2
0
    static void Main(string[] args)
    {
        AddCollection      ac     = new AddCollection();
        AddRemoveColection arc    = new AddRemoveColection();
        MyList             myList = new MyList();

        var input = Console.ReadLine().Split();

        foreach (var item in input)
        {
            Console.Write($"{ac.Add(item)} ");
        }
        Console.WriteLine();
        foreach (var item in input)
        {
            Console.Write($"{arc.Add(item)} ");
        }
        Console.WriteLine();
        foreach (var item in input)
        {
            Console.Write($"{myList.Add(item)} ");
        }
        Console.WriteLine();

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

        for (int i = 0; i < count; i++)
        {
            Console.Write($"{arc.Remove()} ");
        }
        Console.WriteLine();
        for (int i = 0; i < count; i++)
        {
            Console.Write($"{myList.Remove()} ");
        }
        Console.WriteLine();
    }