!s.empty() && std::all_of(s.begin(), s.end(), ::isdigit);
79 const char*op = operation.c_str();
102std::cout <<
"Operator not defined\n";
114template<std::
size_tN>
120std::string scan = input[j];
147std::array<std::string, 7> input = {
"2",
"3",
"1",
"*",
"+",
"9",
"-"};
151assert(answer == -4);
160std::array<std::string, 9> input = {
"100",
"200",
"+",
"2",
"/",
161 "5",
"*",
"7",
"+"};
164assert(answer == 757);
175std::cout <<
"\nTest implementations passed!\n";
Creates an array to be used as stack for storing values.
int stackTop
Represents the index of the last value added to array. -1 means array is empty.
std::array< float, 20 > stack
Array which will be used to store numbers in the input.
for std::invalid_argument
std::shared_ptr< Node< value_type > > stackTop
Functions for Postfix Expression algorithm.
char pop()
pop a byte out of stack variable
bool is_number(const std::string &s)
Checks if scanned string is a number.
void evaluate(float a, float b, const std::string &operation, Stack *stack)
Evaluate answer using given last two operands from and operation.
static void test_function_2()
Test function 2 with input array {'1', '2', '+', '2', '/', '5', '*', '7', '+'}.
static void test_function_1()
Test function 1 with input array {'2', '3', '1', '*', '+', '9', '-'}.
void push(float operand, Stack *stack)
Pushing operand, also called the number in the array to the stack.
float postfix_evaluation(std::array< std::string, N > input)
Postfix Evaluation algorithm to compute the value from given input array.
int main()
Main function.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4