Question
C++ How to Check if Expressions are Similar I have the two given files: a+B-A-1+3+b a+B-A+0+2+b +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B) (newline) a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B a+B-A+1+1+b (newline)
C++ How to Check if Expressions are Similar
I have the two given files:
a+B-A-1+3+b a+B-A+0+2+b +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B)
(newline)
a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B a+B-A+1+1+b (newline)
Expected Output (Is Similar):
"Yes"
A+B+5+6+a A-B+5+6+a
(newline)
Expected Output (Is NOT Similar)
"No"
How can the code be written so that it checks that every expression within the file is similar to each other?
If every expression is similar, it simply outputs "Yes", otherwise, there exists an expression that is not similar and only outputs "No"
I'm able to check if the file has balanced brackets, but I'm not sure how to go about checking that they're similar?
Thanks
EDIT: I'm thinking I should convert every expression to postfix but I'm not sure on the implementation of that either.
a+B-A-1+3+b a+B-A+0+2+b +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B) a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B a+B-A+1+1+b A+B+5+6+a A-B+5+6+a a+B-A-1+3+b a+B-A+0+2+b +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B) a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B a+B-A+1+1+b A+B+5+6+a A-B+5+6+aStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started