I am doing my C++ homework but I cannot figure out the algorithm.
I have to make a program that operates with strings.
The strings and operators(+ and *) should be differentiated by space(' ')
and multiplication operates first than addition
+) use atoi to change string to integer
for example :
INPUT : abc + b * 4 + xy * 2 + z
OUTPUT : abcbbbbxyxyz
so far this is what I did ↓
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include<sstream>
using namespace std;
enum classify {NUMBER, STRING, OPERATION, SPACE};
int char_type(string c)
{
if (c >= "0" && c <= "9") return NUMBER;
else if (c == "*" || c == "+") return OPERATION;
else if (c == " ") return SPACE;
else return STRING;
}
int main(void)
{
string input;
getline(cin, input);
istringstream token(input);
string buffer;
while (getline(token, buffer, ' '))
{ after I classify them using enum, how can I
let the computer to know "multiplication first"? }
}