<<simple program using Stacks - questions
I am having alot of trouble figuring out this program...any help would be greatly appreciated...
Write a program that prompts for a file name and then reads the file to
check for balanced curly braces, {}; parentheses, (); and square brackets,
[]. Use a stack to store the most recent unmatched left symbol. The program
should ignore character that is not a parenthesis, curly brace, or square
bracket. Note that proper nesting is required. For instance, [a(b]c) is
invalid.
Code:
Output
1. {{a+5}-7*[1-{4/2}]}/{2*(3-6)} Valid
2. {(a+5)-7*[1-{4/2}])/{2*(3-6)} Invalid
I know how to read chars from the file...etc. i'm just having problems figuring out how to go about solving this....i cant seem to figure out a proper algorithm that'll do what the problem is asking.....help!!