fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. public class Main
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. int testCases = Integer.parseInt(br.readLine());
  14. for (int i=0;i<testCases;i++) {
  15. String str = br.readLine();
  16. StringBuilder str1 = new StringBuilder();
  17. for (int j=0;j<str.length();j++) {
  18. if(str.charAt(j)=='(') {
  19. continue;
  20. }else if(Character.isAlphabetic(str.charAt(j))) {
  21. System.out.print(str.charAt(j));
  22. }else if (str.charAt(j) == ')') {
  23. System.out.print(str1.charAt(str1.length()-1));
  24. str1.deleteCharAt(str1.length()-1);
  25. }else {
  26. str1.append(str.charAt(j));
  27. }
  28. }
  29. str1.reverse();
  30. System.out.println(str1);
  31. }
  32.  
  33. }
  34. }
Runtime error #stdin #stdout #stderr 0.1s 320576KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.NumberFormatException: null
	at java.lang.Integer.parseInt(Integer.java:542)
	at java.lang.Integer.parseInt(Integer.java:615)
	at Ideone.main(Main.java:14)