ex01: fix: maybe useless
This commit is contained in:
parent
481de18bbd
commit
eb1819276f
@ -13,7 +13,7 @@ int multiplication(int a, int b) { return (a * b); }
|
||||
int calculate(std::stack<int>& nums, std::stack<char>& operators)
|
||||
{
|
||||
if (nums.size() < 2 || operators.size() == 0)
|
||||
return 0;
|
||||
return 2;
|
||||
|
||||
int ret;
|
||||
int b = nums.top();
|
||||
@ -62,11 +62,14 @@ int main(int ac, char** av)
|
||||
else if (std::strchr("/+-*", av[1][i]) != NULL)
|
||||
{
|
||||
operators.push(av[1][i]);
|
||||
if (calculate(nums, operators))
|
||||
int ret = calculate(nums, operators);
|
||||
if (ret == 1)
|
||||
{
|
||||
std::cout << "error: division by 0" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else if (ret == 2)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user