Frames

Untitled

0
1import java.io.BufferedReader;
2import java.io.InputStreamReader;
3import java.io.IOException;
4import java.util.Stack;
5
6class Bracket {
7 Bracket(char type, int position) {
8 this.type = type;
9 this.position = position;
10 }
11
12 boolean Match(char c) {
13 if (this.type == '[' && c == ']')
14 return true;
15 if (this.type == '{' && c == '}')
16 return true;
17 if (this.type == '(' && c == ')')
18 return true;
19 return false;
20 }
21
22 char type;
23 int position;
24}
25
26class check_brackets {
27 public static void main(String[] args) throws IOException {
28 InputStreamReader input_stream = new InputStreamReader(System.in);
29 BufferedReader reader = new BufferedReader(input_stream);
30 String text = reader.readLine();
31
32 Stack<Bracket> opening_brackets_stack = new Stack<Bracket>();
33 for (int position = 0; position < text.length(); ++position) {
34 char next = text.charAt(position);
35
36 if (next == '(' || next == '[' || next == '{') {
37 // Process opening bracket, write your code here
38 }
39
40 if (next == ')' || next == ']' || next == '}') {
41 // Process closing bracket, write your code here
42 }
43 }
44
45 // Printing answer, write your code here
46 }
47}
48