Vectors-Lists-and-Iterators-Exercise - Brackets
Write a program which reads a single line from the console, containing brackets for a mathematical expression (only the brackets will appear in the input), and determines whether the brackets in the expression are correct. There are 3 types of brackets – {}, [] and (). {} can contain {}, [] and () brackets. Square brackets [] can contain [] and () brackets. Curved () brackets can contain only () brackets. Said simply, each type of brackets can contain the same type of brackets inside, or a “lower” type of brackets (() is lower than [] which is lower than {}). If a bracket of one type is opened, it needs to be closed before a bracket of another type is closed.
Print valid if the brackets in the expression are valid and invalid if they are not.
Examples
Input Output
[()]{}{[()()]()} valid
[(]) invalid
([]) invalid
()[[[()]]]{[()]} valid
Пробвах да направя булеви функции за трите вида скоби, но май не ги имплементирах правилно в main-a. Кажете ми дали съм на прав път или да търся коренно различен подход.
https://pastebin.com/3JqVWsqV