Torres de hanoi

Páginas: 3 (695 palabras) Publicado: 4 de abril de 2011
class Aguja
{
public:
Aguja();
bool vacia();
int tamañoDiscoTope();
void agregarDisco(const int &tamaño);
void quitarDisco();
int verCantDiscos();
void exportarInfoGrafico(inta[]);

private:
int discos[11];
int cantDiscos;
};

Aguja::Aguja()
{
cantDiscos = 0;
for(int i = 0; i <= 10; i++)
discos[ i ] = 0;
}

bool Aguja::vacia()
{
returncantDiscos == 0;
}

int Aguja::tamañoDiscoTope()
{
return discos[cantDiscos - 1] * (cantDiscos > 0);
}
void Aguja::agregarDisco(const int &tamaño)
{
discos[cantDiscos] = tamaño;cantDiscos++;
}
void Aguja::quitarDisco()
{
cantDiscos--;
discos[cantDiscos] = 0;
}

int Aguja::verCantDiscos()
{
return cantDiscos;
}

void Aguja::exportarInfoGrafico(inta[])
{
for(int i = 0; i <= 10; i++)
a[ i ] = discos[ i ];
}

class TorresDeHanoi
{
public:
TorresDeHanoi(int cant);
void moverUnDisco(const int &origen, const int&destino);
void moverMuchosDiscos(int cant, const int &origen, const int &destino);
void mostrarGrafico();
void establecerCantDiscos(const int &);
void agregarGraficos();
voidquitarGraficos();
int obtenerCantDiscos();
int cantDiscosAguja(const int &);
void obtenerInfoGrafico();
int tamañoDiscoTopeAguja(const int &);
bool agujaVacia(const int &aguj);private:
Aguja agujas[3];
int totalDiscos;
bool conGraficos;
void decidirMovimientoPar();
int posDiscoMenor;
int infoGrafico[3][11];
};

#include <iostream>
using std::cout;using std::cin;
using std::endl;

#include <cstdlib>
using std::system;

TorresDeHanoi::TorresDeHanoi(int cant)
{
establecerCantDiscos(cant);
agregarGraficos();

while(cant >0)
{
agujas[0].agregarDisco(cant);
cant--;
}

posDiscoMenor = 1;
}

void TorresDeHanoi::moverUnDisco(const int &origen, const int &destino)
{

agujas[destino -...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Torres de hanoi
  • TORRES DE HANOI
  • Torre de hanoi
  • Torre de hanoi
  • Torres de hanoi
  • Torre de hanoi
  • torres de hanoi
  • torres de hanoi

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS