예제 #1
0
        public static Lista Llenar(Lista lista)
        {
            ConsoleKeyInfo op;
            bool           salir = false;

            do
            {
                Console.Clear();
                Console.WriteLine("Ingrese la cadena: ");
                string cad = Console.ReadLine();
                lista.Agregar(cad);
                do
                {
                    Console.WriteLine("Desea agregar otra cadena?(s/n)");
                    op = Console.ReadKey();
                    if (op.Key == ConsoleKey.N)
                    {
                        salir = true;
                        break;
                    }
                    else if (op.Key == ConsoleKey.S)
                    {
                        salir = false;
                    }
                    else
                    {
                        salir = true;
                    }
                    Console.Clear();
                } while (salir);
            } while (!salir);
            return(lista);
        }//opcion 1
예제 #2
0
        public void Insertar_posicion(int posicion, string item)
        {
            Lista ap    = this;
            Lista nuevo = new Lista(item);

            if (posicion == 0)
            {
                ArrayList aux = new ArrayList();
                aux = this.toArray();
                foreach (string nodo in aux)
                {
                    nuevo.Agregar(nodo);
                }
                this.elemento = nuevo.elemento;
                this.sig      = nuevo.sig;
            }
            else
            {
                if (!Vacia() && posicion < Contar)
                {
                    for (int i = 0; i < posicion; i++)
                    {
                        ap = ap.sig;
                    }
                    nuevo.sig = ap.sig;
                    ap.sig    = nuevo;
                }
            }
        }