#include <vector>
#include <iostream>
#include <string.h>
using namespace Std;
void Pr (char *str)
{
cout<< "Formula Length:" <<strlen (str);
vector<char> S1 (strlen (str));
Vector<char> S2 (strlen (str));
int i=0;
while (str[i]!= ')
{
if (str[i]>= ' 0 ' &&str[i]<= ' 9 ')
{
Char Ch=str[i];
S1.push_back (CH);
i++;
}
else if (str[i]== ') ')
{
while (S2.back ()! = ' (')
{
Char Ch=s2.back ();
S1.push_back (CH);
S2.pop_back ();
}
S2.pop_back ();
i++;
}
else if (str[i]== ' + ' | | str[i]== '-')
{
if (s2.back () = = ' * ' | | S2.back () = = '/')
{
S1.push_back (S2.back ());
S2.pop_back ();
S2.push_back (Str[i]);
i++;
}
else{
S2.push_back (str[i++]);
}
}
else{
S2.push_back (str[i++]);
}
}
while (!s2.empty ())
{
S1.push_back (S2.back ());
S2.pop_back ();
}
Vector<char>::iterator it;
For (It=s1.begin (); It<s1.end (); it++)
{
cout<<*it<< "";
}
}
int main ()
{
Char str[]= "(4+6)-7";
PR (str);
return 0;
}
There are shortcomings in the consideration of the ill-conceived and criticized
4+6-7 # Implement this expression in code, containing only the inverse Polish part, the arithmetic result part is not written