Now, I posted the algorithm for this address below here because I had problems with unpacking and removing was solved until then. Deploying Dynamic Stack
But as I was reviewing the code and therefore leaving them better I decided to put a for
so that the user is not typing 1 in the menu to enter the numbers, then he would do the insertion according to the size of the vector:
So I did this below:
if(op == 1)
{
for(i=0;i<=9;i++)
{
std::cout << "\n\tINSIRA NUMERO "<<i+1<<" NA PILHA: ";
pilha *novo = new pilha();
std::cin >> novo->num[i];
novo->prox = topo;
topo = novo;
std::cout << "\n\tNUMERO "<<novo->num[i]<<" INSERIDO COM SUCESSO!!!";
}
}
But when I type 2 it returns all zero. What did I do wrong?
if(op == 2)
{
i++;
if(topo == NULL)std::cout << "\n\tPILHA VAZIA!!!";
else
{
std::cout << "\n\tPILHA COMPLETA: ";
aux = topo;
while(aux != NULL)
{
std::cout << aux->num[i] << " ";
aux = aux->prox;
}
}
}