Nie rozumiem czemu na wyjściu w stosie pojawia się liczba której nawet się na ten stos nie dopisywało, jak to wytłumaczyć?
#include <iostream>
#include <stack>
using namespace std;
int main() {
stack <int> stos;
char x;
while(cin>>x)
{
if(x=='+')
{
if(stos.size()>=10) cout<<":("<<endl;
else if(stos.size()<10)
{
cin>>x;
stos.push(x);
cout<<":)"<<endl;
}
}
else if (x=='-')
{
if(stos.size()<=0) cout<<":("<<endl;
else if(stos.size()>=0)
{cout<<stos.top()<<endl;
stos.pop();
}
}
}
return 0;
}