subject

You are given a string consisting of parenthesis style characters ( ) [ ] and { }. A string of this type is said to be correct if: (a) It is an empty string. (b) If string A is correct and string B is correct then string AB is correct. (c) If A is correct then (A), [A] and {A} are all correct. You are to write a program that takes as input from the keyboard a series of strings of this type that can be of any length. The first line of input will contain a single integer n telling you how many strings you will be testing. Following that integer will be n lines (each ending in a new line character) that represent the strings you are supposed to test with one string per line. Your program should output Yes if a given string is correct and No otherwise. For example if the user types the following as input 3 ([]) (([{}]))) ([()[]()])() Then your program should give the following output: Yes No Yes You will note that if you do your program correctly there is no prompt for data and the yes and no answers will be interspersed with your input data when you enter it manually. The following would be a more accurate representation of what you see on the screen when you cut and paste the input into your program. 3 ([]) Yes (([{}]))) No ([()[]()])() Yes You may find it useful to use a text file for testing your code so that you do not have to keep retyping the tests. You can do this from the command line by typing the name of the executable file followed by a less than sign and the name of your file.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:20
What do you need to know & understand about global expansion.
Answers: 2
question
Computers and Technology, 23.06.2019 06:30
Who can provide you with a new password when you have forgotten your old one? your provide you with a new password in case you forget your old one.
Answers: 3
question
Computers and Technology, 23.06.2019 06:30
You have a small company and want to keep your costs low, but it is important your employees share data. which network would provide you with the most economical solution?
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
Write a program that prints the day number of the year, given the date in the form month-day-year. for example, if the input is 1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. the program should check for a leap year. a year is a leap year if it is divisible by 4, but not divisible by 100. for example, 1992 and 2008 are divisible by 4, but not by 100. a year that is divisible by 100 is a leap year if it is also divisible by 400. for example, 1600 and 2000 are divisible by 400. however, 1800 is not a leap year because 1800 is not divisible by 400.
Answers: 3
You know the right answer?
You are given a string consisting of parenthesis style characters ( ) [ ] and { }. A string of this...
Questions
question
Social Studies, 27.03.2020 00:42
question
Mathematics, 27.03.2020 00:43
question
English, 27.03.2020 00:43
Questions on the website: 13722362