//archivo cpila.h
// Class automatically generated by Dev-C++ New Class wizard
#include <iostream>
#ifndef CPILA_H
#define CPILA_H
/*
* No description
*/
class cpila
{
char pila[50];
int tope;
public:
// class constructor
cpila();
// class destructor
~cpila();
void poner(char c);
char sacar();
void imprimirpila();
};
#endif // CPILA_H
//archivo cpila.cpp
// Class automatically generated by Dev-C++ New Class wizard
#include <cstdlib>
#include <iostream>
#include <cctype>
#include <cstdio>
#include <conio.h>
#include "cpila.h" // class's header file
using namespace std;
// class constructor
cpila::cpila()
{
// insert your code here
//pila[0]='\0';
tope=0;
cout << "Tope al crear la pila:" << tope << endl;
}
// class destructor
cpila::~cpila()
{
// insert your code here
pila[0]='\0';
}
void cpila::poner(char c) {
tope=tope+1;
//cout << "Tope´al poner:" << c << " " << tope << endl;
pila[tope]=c;
}
char cpila::sacar(){
char ctope=pila[tope];
tope--;
//cout << "Tope al sacar:" << ctope << " " << tope << endl;
return(ctope);
}
void cpila::imprimirpila() {
for(int i=tope;i>=1;i--) {
cout << pila[i] << endl;
}
}
//archivo maincpila.cpp
#include <cstdlib>
#include <iostream>
#include <cctype>
#include <cstdio>
#include "cpila.h"
using namespace std;
int main(int argc, char *argv[])
{
cpila pila;
char c;
pila.poner('a');
pila.poner('b');
pila.poner('c');
cout << "Pila impresa:" << endl;
pila.imprimirpila();
c=pila.sacar();
cout << c << endl;
c=pila.sacar();
cout << c << endl;
c=pila.sacar();
cout << c << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
// Class automatically generated by Dev-C++ New Class wizard
#include <iostream>
#ifndef CPILA_H
#define CPILA_H
/*
* No description
*/
class cpila
{
char pila[50];
int tope;
public:
// class constructor
cpila();
// class destructor
~cpila();
void poner(char c);
char sacar();
void imprimirpila();
};
#endif // CPILA_H
//archivo cpila.cpp
// Class automatically generated by Dev-C++ New Class wizard
#include <cstdlib>
#include <iostream>
#include <cctype>
#include <cstdio>
#include <conio.h>
#include "cpila.h" // class's header file
using namespace std;
// class constructor
cpila::cpila()
{
// insert your code here
//pila[0]='\0';
tope=0;
cout << "Tope al crear la pila:" << tope << endl;
}
// class destructor
cpila::~cpila()
{
// insert your code here
pila[0]='\0';
}
void cpila::poner(char c) {
tope=tope+1;
//cout << "Tope´al poner:" << c << " " << tope << endl;
pila[tope]=c;
}
char cpila::sacar(){
char ctope=pila[tope];
tope--;
//cout << "Tope al sacar:" << ctope << " " << tope << endl;
return(ctope);
}
void cpila::imprimirpila() {
for(int i=tope;i>=1;i--) {
cout << pila[i] << endl;
}
}
//archivo maincpila.cpp
#include <cstdlib>
#include <iostream>
#include <cctype>
#include <cstdio>
#include "cpila.h"
using namespace std;
int main(int argc, char *argv[])
{
cpila pila;
char c;
pila.poner('a');
pila.poner('b');
pila.poner('c');
cout << "Pila impresa:" << endl;
pila.imprimirpila();
c=pila.sacar();
cout << c << endl;
c=pila.sacar();
cout << c << endl;
c=pila.sacar();
cout << c << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
No hay comentarios:
Publicar un comentario