예제 #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);
        }
        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);
        }
예제 #3
0
        static public void Mostrar(Lista_Enlazad lista)
        {
            Console.Clear();
            Console.Title = "Mostrar Lista";

            NodoLista aux  = lista.cabeza;
            int       cont = 1;

            //Ciclo para imprimir hasta que el sig apuntador sea null
            while (aux != null)
            {
                Console.WriteLine($"{cont}.- Nombre: {aux.Nombre}");
                aux.ArrInt.ImprimirEnL();
                Console.WriteLine();
                cont++;

                //Se cambia auxiliar por el apuntador del siguiente
                aux = aux.SiguienteNodo;
            }

            //Imprimir null en caso de que el apuntador sea null
            if (aux == null)
            {
                Console.WriteLine("No hay más arreglos");
            }

            aux = null;

            Console.WriteLine();
        }
예제 #4
0
        static public bool Existe(Lista_Enlazad lista, string nombre)
        {
            //Error lista
            aux = lista.cabeza;
            bool existe = false;

            //Ciclo para hacer recorrido
            while (aux != null)
            {
                if (aux.Nombre == nombre)
                {
                    existe = true;
                }

                aux = aux.SiguienteNodo;
            }

            if (!existe)
            {
                Console.Clear();
                Console.Beep();
                Console.WriteLine("El arreglo no existe dentro de la lista");
                System.Threading.Thread.Sleep(2000);
            }

            return(existe);
        }
예제 #5
0
 static public bool Verifica_Vacia(Lista_Enlazad list)
 {
     if (list.cabeza == null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #6
0
        static public int ContarElementos(Lista_Enlazad lista)
        {
            Lista_Enlazad aux      = lista;
            int           contador = 1;

            while (aux != null)
            {
                aux.cabeza = aux.cabeza.SiguienteNodo;
                contador  -= -1;
            }

            Console.WriteLine($"Tiene {contador} elementos en la lista");

            return(contador);
        }
예제 #7
0
        static public int[] Solicitar(Lista_Enlazad lista, string nombre)
        {
            aux = lista.cabeza;

            while (aux != null)
            {
                if (aux.Nombre == nombre)
                {
                    ArrAux = aux.ArrInt;
                }

                aux = aux.SiguienteNodo;
            }

            return(ArrAux);
        }
        public static void MenuL1(ref Lista_Enlazad lista)
        {
            bool rep = true;

            try
            {
                do
                {
                    Console.Clear();
                    Console.Title = "Menu Principal - Programa Ordenamiento";
                    Console.WriteLine("1.-Crear Arreglo");
                    Console.WriteLine("2.-Mostrar Arreglos");
                    Console.WriteLine("3.-Arreglos predefinidos");
                    Console.WriteLine("4.-Arreglo aleatorio");
                    Console.WriteLine("5.-Ordenar Arreglo");
                    Console.WriteLine("6.-Información del programa");
                    Console.WriteLine("7.-Salir del Programa");

                    switch (int.Parse(Console.ReadLine()))
                    {
                    case 1:
                        CrearArreglo(ref lista);
                        break;

                    case 2:
                        Lista_Enlazad.Mostrar(lista);
                        Console.ReadKey();
                        rep = true;
                        break;

                    case 3:
                        break;

                    case 4:
                        break;

                    case 5:
                        break;

                    case 6:
                        Console.Title = "Información";
                        Console.Clear();
                        Console.WriteLine("Materia: Estructura de Datos");
                        Console.WriteLine("Docente: ING.NANCY GABRIELA MARÍN CASTAÑEDA");
                        Console.WriteLine("Tercer Semestre | Grupo A | Agosto - Diciembre");
                        Console.WriteLine("Programa hecho por:");
                        Console.WriteLine("\tVictor Hugo Carreon Pulido -192310436");
                        Console.WriteLine("\tAndrea Evelyn Mejia Rubio -192310177");
                        Console.WriteLine("\tEdgar Eduardo Arguijo Vazquez -192310252");
                        Console.ReadKey();
                        rep = true;
                        break;

                    case 7:
                        Environment.Exit(0);
                        break;


                    default:
                        Console.Clear();
                        Console.WriteLine("Elija una opción válida");
                        rep = true;
                        break;
                    }
                } while (rep);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #9
0
 static public void Vaciar(ref Lista_Enlazad lista)
 {
     lista = null;
 }