Program goal: user input for 2 equations to evaluate the operator signs. i.e. 1 * 2 + 4 - 4
and 5 - 2 * 6 + 9 would be the same --> " * + - " in both, order does not matter.
Output: cout saying match or not match.
I'm not sure how to go about checking the operators in the best/easiest fashion, in the main(), or in my cpp file where 90% of the "work" is happening. I've tried all "i" know to do. Obviously I'm missing something, and/or went about this program totally abstract. But, I am basically teaching myself and slightly struggling. So.. he's the code:
stack s1;
stack s2;
char ch1=NULL
ch2=NULL;
if(s1.empty())
cout << "stack currently empty...\n" << endl; // check if stack is empty
cout << "enter first set: ";
while ((ch1 = cin.get())!= '\n'){
if (!s1.full()) s1.push(ch1,ch2);
while (!s1.empty())
cout << s1.pop();
}//end whiles s1
cout << "\nenter second set: ";
while ((ch2 = cin.get())!= '\n'){
if (!s2.full()) s2.push(ch1,ch2);}
while (!s2.empty()){
cout << s2.pop();
}//end whiles s2
// not a good place to check I'm thinking...
void stack::push(int a,int b) {
char p ='+',
s= '-',
m = '*',
d = '/',
e = '=';
char pp ='+',
ss = '-',
mm = '*',
dd = '/',
ee = '=';
if(a == p){
cout << p;
p++;}
if(a == s){
cout << s;
s++;}
if(a == m){
cout << m;
m++;}
if(a == d){
cout << d;
d++;}
if(a == e){
cout << e;
e++;}
/*--------------------------------------
if int a, int b operator seperator
---------------------------------------*/
if(b == pp){
cout << pp;
pp++;}
if(b == ss){
cout << ss;
ss++;}
if(b == mm){
cout << mm;
mm++;}
if(b == dd){
cout << dd;
dd++;}
if(b == ee){
cout << ee;
ee++;}
//better place to check..how is a different story.
}// end stack::push