RPN: use float
This commit is contained in:
parent
fee188de95
commit
0852968609
@ -10,7 +10,7 @@ int addition(int a, int b) { return (a + b); }
|
|||||||
int division(int a, int b) { return (a / b); }
|
int division(int a, int b) { return (a / b); }
|
||||||
int multiplication(int a, int b) { return (a * b); }
|
int multiplication(int a, int b) { return (a * b); }
|
||||||
|
|
||||||
int calculate(std::stack<int>& nums, std::stack<char>& operators)
|
int calculate(std::stack<float>& nums, std::stack<char>& operators)
|
||||||
{
|
{
|
||||||
if (nums.size() < 2 || operators.size() == 0)
|
if (nums.size() < 2 || operators.size() == 0)
|
||||||
return 2;
|
return 2;
|
||||||
@ -50,7 +50,7 @@ int main(int ac, char** av)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stack<int> nums;
|
std::stack<float> nums;
|
||||||
std::stack<char> operators;
|
std::stack<char> operators;
|
||||||
|
|
||||||
for (size_t i = 0; av[1][i] != '\0'; i++)
|
for (size_t i = 0; av[1][i] != '\0'; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user