ZERO314 @ 2024-08-18 16:09:46
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedList<String> list = new LinkedList();
Scanner sc = new Scanner(System.in);
String s = sc.next();
for (int i = 0; i < s.length(); i++) {
list.add(i, s.substring(i,i+1));
}
for (int i = 0; i < s.length(); i++) {
String c = list.get(i);
switch(c) {
case "(":
for (int j = i+1; j < s.length(); j++) {
if(list.get(i)==")") {
System.out.print(c+j);
break;
}
}
System.out.print(c+")");
break;
case "[":
for (int j = i+1; j < s.length(); j++) {
if(list.get(i)=="]") {
System.out.print(c+j);
break;
}
}
System.out.print(c+"]");
break;
}
}
}
}