MARCO
MARCO
MARCO
“AñodelaUniversalizacióndelaS
alud”
ESTRUCTURA DE DATOS
NRC: 14873
DNI: 44016920
2022
CODIGO FUENTE:
#include <iostream>
#include <clocale>
#include<string>
#include <cstdlib>
#include <vector>
using namespace std;
struct pokemon{
string nombre;
int poder;
string tipo;
pokemon *pNodo;
};
int nroDigito=1;
bool lbExiste = false;
vector<string> vectorNombre;
vector<string>::iterator it;
string listaPokemones[10][4]={
{"0","Pikachu","140","Eléctrico"},{"1","Charizard","135","Fuego"},
{"2","Squirtle","110","Agua"},
{"3","Jigglypuff","60","Ada"},{"4","Eevee","90","Normal"},
{"5","Gengar","80","Fantasma"},
{"6","Mewtwo","140","Legendario"},{"7","Mew","100","Legendario"},
{"8","Lugia","70","Legendario"},
{"9","Gyrados","78","Agua"}
};
int main() {
setlocale(LC_CTYPE,"Spanish");
mostrarData();
pokemon *nodo = NULL;
int *opt = new int;
do{
menu();
*opt = pedirop();
switch(*opt){
case 1: apilar(nodo); break;
case 2: desapilar(nodo); break;
case 3: mostrar(nodo); break;
case 4: vaciar(nodo); break;
case 5: cout<<"\nGracias!\n"; break;
}
}while(*opt!=5);
vaciar(nodo);
delete opt;
return 0;
}
do{
lbExiste = false;
cout<<"Ingrese el digito 0"<<nroDigito<<" de su dni: ";
cin>>lsDigito;
if (isNumber(lsDigito)){
lnDigito = std::atoi(lsDigito.c_str());
if (lnDigito < 0 || lnDigito > 9){
lbInicia = false;
cout<<"El valor ingresado debe encontrarse entre 0 y
9"<<endl;
} else {
existe(lsDigito);
if (!lbExiste){
for (int i=0; i<10; i++)
{
if (listaPokemones[i][0] == lsDigito){
nodo->nombre=listaPokemones[i][1];
nodo->poder=std::atoi(listaPokemones[i]
[2].c_str());
nodo->tipo=listaPokemones[i][3];
vectorNombre.push_back(listaPokemones[i]
[1]);
cout<<"El pokemon "<<nodo->nombre<<" fue
registrado"<<endl;
break;
}
}
nroDigito = nroDigito + 1;
}
lbInicia = true;
}
} else {
lbInicia = false;
cout<<"El valor ingresado no es correcto"<<endl;
}
} while (!lbInicia);
return;
}
nroDigito = 1;
it = vectorNombre.begin();
vectorNombre.erase(it);
cout<<"\nPila destruida\n";
}else{
cout<<"\nLa pila está vacia\n";
}
return;
}
void menu(){
cout<<"\n*** MENU DE POKEMON **\n";
cout<<"\n[1] Apilar";
cout<<"\n[2] Desapilar";
cout<<"\n[3] Mostrar Nodo";
cout<<"\n[4] Vaciar Nodo";
cout<<"\n[5] Salir";
return;
}
int pedirop(){
int *x = new int;
do{
cout<<endl;
cout<<"\nIngrese opción: [1-5]: ";
cin>>*x;
cout<<endl;
if(*x<1||*x>5)
cout<<"\nError...";
}while(*x<1||*x>5);
return *x;
}
void mostrarData(){
string caracterIni, space, caracterFin;
cout<< endl;
cout<<"--------- LISTA DE POKEMONES PERMITIDOS ---------"<< endl;
cout<< endl;
cout<<"------------------------------------------------"<< endl;
cout<<"* NRO || NOMBRE || PODER || TIPO *"<<endl;
cout<<"------------------------------------------------"<< endl;
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 4; j++)
{
//cout<<listaPokemones[i][0]<<endl;
if (j==0){
caracterIni = "* ";
space =" || ";
caracterFin= "*";
} else if(j==1){
caracterIni = "";
space =" || ";
} else if(j==2){
caracterIni = "";
space =" ||";
} else if(j==3){
caracterIni = "";
space =" *";
}
cout<<caracterIni<<listaPokemones[i][j]<<space;
}
cout<<endl;
}
cout<<"--------------------------------------------------"<< endl;
}