Ejemplo n.º 1
0
        static public Lista_Enlazad Eliminar(NodoLista Lista, string nombre)
        {
            Lista_Enlazad Aux = new Lista_Enlazad();

            if (Lista.Nombre == nombre)
            {
                Aux.InsertarALaCabeza(Lista.SiguienteNodo);
                return(Aux);
            }
            else
            {
                while (Lista.SiguienteNodo != null)
                {
                    if (Lista.Nombre == nombre)
                    {
                        Aux.InsertarALaCabeza(Lista.SiguienteNodo);
                    }

                    Aux.InsertarALaCabeza(Lista);
                    Lista = Lista.SiguienteNodo;
                }
            }

            return(Aux);
        }
Ejemplo n.º 2
0
        static public void CrearArreglo(ref Lista_Enlazad list)
        {
            int[] arreglo = null;
            bool  rep     = true;

            do
            {
                try
                {
                    Console.Write("Escriba el nombre de su arreglo:");
                    string nombre = Console.ReadLine();
                    Console.WriteLine("Escriba los elementos del arreglo separados por un espacio");
                    string elementos = Console.ReadLine();
                    arreglo = Array.ConvertAll(elementos.Split(' '), s => int.Parse(s));
                    NodoLista nodo = new NodoLista(arreglo, nombre);
                    list.InsertarALaCabeza(nodo);
                    rep = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    rep = true;
                }
            } while (rep);
        }