Your friend keeps finding mistakes in his code due to unmatched brackets errors. You, as a good friend, decided to help him by developing a program that will find and solve errors in the usage of different types of brackets. A Code can contain any of the following brackets []{}(), where the opening brackets are [{, and (and the closing brackets corresponding to them are ],}, and ). Being a good friend, you want your program not to only detect that there is an error in the usage of brackets, but also solve it. 1. Write a program that finds the first unmatched closing bracket which either does not have an opening bracket before it, or closes the wrong opening bracket, like } in ()[}. If there are no such mistakes, then it should find the first unmatched opening bracket without the corresponding closing bracket after it, like (in {}([]. If there are no mistakes, you should output same input. 2. If there exists a mistake then your program should output the right form of the input after solving a problem. Input Samples: Your program should be written to take the input in the exact format shown in the following samples (Don't ask the user to enter his input just take input as follows and only print the required output): Sample 1 Input Hello (Ahmed)! Hello (Ahmed)! output Sample 2 Input output {[]}( {[]}0) Sample 3 Input output |{ {}

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

c++/data structures

Problem Description:
Your friend keeps finding mistakes in his code due to unmatched brackets errors. You, as a good
friend, decided to help him by developing a program that will find and solve errors in the usage of
different types of brackets. A Code can contain any of the following brackets []{}(), where the
opening brackets are [,{, and (and the closing brackets corresponding to them are ],}, and ).
Being a good friend, you want your program not to only detect that there is an error in the usage of
brackets, but also solve it.
1. Write a program that finds the first unmatched closing bracket which either does not
have an opening bracket before it, or closes the wrong opening bracket, like } in ()[}. If there
are no such mistakes, then it should find the first unmatched opening bracket without the
corresponding closing bracket after it, like ( in {}([]. If there are no mistakes, you should
output same input.
2. If there exists a mistake then your program should output the right form of the input
after solving a problem.
Input Samples:
Your program should be written to take the input in the exact format shown in the following samples (Don't ask
the user to enter his input just take input as follows and only print the required output):
Sample 1
Hello (Ahmed)!
Input
output
Hello (Ahmed)!
Sample 2
Input
{[]}()
{[]}()
output
Sample 3
Input
{
output
{}
Transcribed Image Text:Problem Description: Your friend keeps finding mistakes in his code due to unmatched brackets errors. You, as a good friend, decided to help him by developing a program that will find and solve errors in the usage of different types of brackets. A Code can contain any of the following brackets []{}(), where the opening brackets are [,{, and (and the closing brackets corresponding to them are ],}, and ). Being a good friend, you want your program not to only detect that there is an error in the usage of brackets, but also solve it. 1. Write a program that finds the first unmatched closing bracket which either does not have an opening bracket before it, or closes the wrong opening bracket, like } in ()[}. If there are no such mistakes, then it should find the first unmatched opening bracket without the corresponding closing bracket after it, like ( in {}([]. If there are no mistakes, you should output same input. 2. If there exists a mistake then your program should output the right form of the input after solving a problem. Input Samples: Your program should be written to take the input in the exact format shown in the following samples (Don't ask the user to enter his input just take input as follows and only print the required output): Sample 1 Hello (Ahmed)! Input output Hello (Ahmed)! Sample 2 Input {[]}() {[]}() output Sample 3 Input { output {}
Sample 4
{}
Input
output
{[]}
Sample 5
Input
output
Foo(bar[i);
Foo(bar[i]);
Sample 6
Input
{[()
output
{[0]}
Notes:
Use a proper data structure that you studied to implement your program. Note that you have to
implement the required data structure by yourself (do not use data structures from Libraries
like STL, provide your own implementation).
Transcribed Image Text:Sample 4 {} Input output {[]} Sample 5 Input output Foo(bar[i); Foo(bar[i]); Sample 6 Input {[() output {[0]} Notes: Use a proper data structure that you studied to implement your program. Note that you have to implement the required data structure by yourself (do not use data structures from Libraries like STL, provide your own implementation).
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY