Professional Documents
Culture Documents
#include
#include
#include
<stdio.h>
<ncurses.h>
<stdlib.h>
<iostream>
}
void imprimir (PTRNODO inicio) {
printf ( "La Lista es:" );
mientras (inicio! = NULL) {
printf ( "% d" , inicio-> dato);
inicio = inicio-> sig;
}
printf ( "\ n" );
}
vaco main_lista () {
PTRNODO inicio = NULL;
Char opcion;
int opc;
int Elemento;
hacer {
printf ( "\ n (1) Insertar \ n (2) ELIMINAR \ n (3) Imprimir \ n (4)
Salir \ n" );
printf ( "\ nSeleccion:" );
scanf ( "% d" , y OPC);
interruptor (opc) {
caso 1:
int qr;
printf ( "Cuantos Elementos DESEA buscas? Busca otros?"
);
scanf ( "% d" , y qr);
para ( int i = 0; i <qr; i ++) {
printf ( "Elemento Ingrese:" );
scanf ( "% d" , y Elemento);
Insertar (y inicio, Elemento);
}
romper ;
caso 2:
si (inicio == NULL) { printf ( "\ n \ nNO HAY ELEMENTOS
!!!! \ n" );
// Romper;
// Goto etiqueta_1;
} otro {
printf ( "Elemento Ingrese:" );
scanf ( "% d" , y Elemento);
Elemento = ELIMINAR (y inicio, Elemento);
si (Elemento == - 1) { printf ( "NO EXISTE EL
ELEMENTO !!!! \ n" );
}
}
romper ;
caso 3:
si (inicio == NULL) { printf ( "No Elementos heno \ n" );
} otro {
imprimir (inicio);
}
romper ;
caso 4:
/// EXIT_SUCCESS;
romper ;
}
} mientras que (opc <4);
}
</ Iostream> </ stdlib.h> </ ncurses.h> </ stdio.h>
#include <stdio.h>
#include <ncurses.h>
#include <iostream>
tam;
Arreglo [tam];
numero, i = 0, x = 0;
borrado;
top = 0;
hacer
{
sistema ( "clear" );
printf
printf
printf
printf
printf
printf
(
(
(
(
(
(
"\
"\
"\
"\
"\
"\
n \ tCOLAS \ n \ n" );
t1 INSERTARn." );
t2 ELIMINARn." );
t3 MOSTRARn." );
t4 SALIRn." );
tQUE DESEA REALIZAR:" );
/
*
*
*
*
*
*
C ++ - Pilas / Pila
Derechos de Autor 2014 Martin Cruz Otiniano
Descripcin: Apila Elemento, Desempila Elemento, Mostrar pila, Destruir Pila
Sitio: www.marcsdev.com
/
std ;
struct nodo {
int nro;
struct nodo * sgte;
};
typedef nodo * ptrPila;
/ * Apilar Elemento
-------------------------------------------------- ---------------------- * /
vaco empuje (ptrPila & p, int valor)
{
aux ptrPila;
aux = nuevo ( struct nodo );
// apuntamos al nuevo nodo CREADO
aux-> nro = valor;
aux-> sgte = p;
p = aux;
}
/ * Desapilar Elemento (Elemento devuelve)
-------------------------------------------------- ---------------------- * /
int pop (ptrPila & p)
{
int num;
aux ptrPila;
aux = p;
num = aux-> nro;
p = aux-> sgte;
eliminar (aux);
volver num;
}
/ * Muestra Elementos de la Pila
-------------------------------------------------- ---------------------- * /
vaco mostrar_pila (ptrPila p)
{
aux ptrPila;
aux = p;
// Apunta al inicio de la Lista
mientras (aux! = NULL )
{
cout << " \ t " << aux-> nro << endl;
aux = aux-> sgte;
}
}
/ * ELIMINAR TODOS LOS Elementos de la Pila
-------------------------------------------------- ---------------------- * /
vaco destruir_pila (ptrPila & p)
{
aux ptrPila;
mientras que (p! = NULL )
{
aux = p;
p = aux-> sgte;
eliminar (aux);
}
}
/ * Men de OPCIONES
-------------------------------------------------- ---------------------- * /
void men ()
{
cout << " \ n \ t IMPLEMENTACION DE PILAS EN C ++ \ n \ n " ;
cout << " 1. apilar
" << endl;
cout << " 2. DESAPILAR
" << endl;
cout << " 3. Mostrar PILA
" << endl;
cout << " 4. Destruir PILA
" << endl;
cout << " 5. SALIR
" << endl;
cout << " \ n Ingrese OPCION: " ;
}
/ * Funcion Principal
-------------------------------------------------- ---------------------- * /
int principal ()
{
ptrPila p = NULL ;
// pila Creando
int dato;
int op;
caso
2 :
x = pop (p);
cout << " \ n \ n \ t \ t Numero " << x << " desapilado ... \ n
\ n " ;
romper ;
caso
3 :
caso
4 :
destruir_pila (p);
cout << " \ n \ n \ t \ t Pila eliminada ... \ n \ n " ;
romper ;
}
cout << endl << endl;
sistema ( " pausa " );
} mientras que (op =! 5 );
volver
}
0 ;