Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
class CEstructura
{
//Atributos
int dato;
int M, N;
int *arreglo;
bool I;
bool vacia;
public:
CEstructura();
~CEstructura();
//Metodos
public:
void crear();
bool probar();
int ver(int);
void insertar(int,int);
void eliminar(int,int);
void destruir(int,int);
void setM(int);
};
___________________________________________________________________________
void CEstructura::eliminar(int k , int dato)
{
int cont = k;
if (k < N)
{
dato = arreglo[k];
while (cont < N)
{
arreglo[cont] = arreglo[cont + 1];
cont++;
}
I = true;
N=N-1;
}
else
{
I = false;
}
}
void CEstructura::destruir(int k,int dato)
{
while (N > 0)
{
int cont = k;
if (k < N)
{
dato = arreglo[k];
while (cont < N)
{
arreglo[cont] = arreglo[cont + 1];
cont++;
}
N = true;
N = N - 1;
}
else
{
I = false;
}
}
N - 1;
}
______________________________________________________________________________
#include <iostream>
#include "CEstructura.h"
#include "CPila.h"
using namespace std;
int main() {
CPila objeto2;
CEstructura lista;
int op = 1;
int tama = 0;
int dat = 0;
int pos = 0;
break;
case 4:
cout << "ingrese posicion\n";
cin >> pos;
cout << "Ingrese datos\n";
cin >> dat;
lista.insertar(pos, dat);
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
}
system("pause");
}
return 0;
}
___________________________________________________________________________________
__________
#include "CPila.h"
#include <iostream>
using namespace std;
bool vaciap = true;
int datopila;
CPila::CPila()
{
}
CPila::~CPila()
{
}
void CPila::crear()
{
cin >> m;
pila = new int[m];
tope=0;
base = 0;
}
bool CPila::probar()
{
if (tope == 0 && base ==0)
{
vaciap= true;
cout << "lista creada";
}
else
{
vaciap = false;
}
return vaciap;
}
void CPila::ver()
{
cout << "El ultimo dato ingresado es " << tope << endl;
}
void CPila::insertar()
{
cout << "Ingrese dato\n";
cin >> datopila;
int j;
if (tope < m)
{
i = true;
if (tope <= tope + 1)
{
j = tope;
while (j > tope) {
pila[j + 1] = pila[j];
j = j - 1;
}
pila[tope] = datopila;
tope = tope + 1;
}
else {
i = false;
}
}
}
___________________________________________________________________________________
__________
#pragma once
class CPila
{
//Atributos
int m, tope = -1;
int base = -1;
int *pila;
bool i;
public:
CPila();
~CPila();
//Metodos
public:
void crear();
bool probar();
void ver();
void insertar();
void eliminar();
void destruir();
};