How can i calculate an expresion of type string:
strng eval = "129 + 23 - 54 * 2 / 4";
Any ideas?
ok,i made the program but it only works with numbers from 0 to 9...if i have lets say 123 + 43 * 23 - 100....how can i push into the stack 123 then 43 then 23 then 100,not 1 2 3 4 3 2 3 1 0 0 ? Thanx
Something like this maybe ... :)
void Load(const string& equation, stack<string>& st)
{
for (string::size_type i(0); i < equation.size(); i++)
{
if (isdigit(equation[i]))
{
string number = "";
number += equation[i];
while (((i + 1) < equation.size()) && isdigit(equation[i + 1]))
{
number += equation[++i];
}
st.push(number);
}
else
{
}
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.