diff --git a/du3/program.c b/du3/program.c index 88d993a..e423d35 100644 --- a/du3/program.c +++ b/du3/program.c @@ -1,6 +1,112 @@ #include +#include +#include + +float plus(float total, float number); +float minus(float total, float number); +float divided(float total, float number); +float multiplied(float total, float number); + int main() { + char buffer[999]; + char row[999]; + char equation[999][20]; + char output[999][10]; + int output_length = 0; + int index = 0; + int eq_index = 0; + while (fgets(buffer, sizeof(buffer), stdin) != NULL) { + if (buffer[0] == '\n') break; + index = 0; + eq_index = 0; + int eq_operand_length = 0; + while (buffer[index] != '\n') { + if (buffer[index] != ' ') { + equation[eq_index][eq_operand_length] = buffer[index]; + eq_operand_length++; + } + else { + equation[eq_index][eq_operand_length] = '\0'; + eq_operand_length = 0; + eq_index++; + } + index++; + } + float total = 0.0; + int sign = 0; + char out[10] = ""; + int n_of_signs = 0; + char operators[6] = "+-=*/"; + char last_operator = '+'; + for (int i=0;i