Go to diff to previous submission
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package bugs; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; import org.omg.PortableInterceptor.SYSTEM_EXCEPTION; /** * * @author student */ public class Bugs { /** * @param args the command line arguments */ while (sc.hasNext()) { int rowCount = sc.nextInt(); for (int i = 0; i < rowCount; i++) { } } } }
--- c4.s966.cteam124.bugs.java.0.Bugs.java +++ c4.s1046.cteam124.bugs.java.0.Bugs.java @@ -10,4 +10,6 @@ import java.io.InputStreamReader; import java.util.ArrayList; +import java.util.Scanner; +import org.omg.PortableInterceptor.SYSTEM_EXCEPTION; /** @@ -21,27 +23,16 @@ */ public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringBuffer row = new StringBuffer(br.readLine()); - - ArrayList<String> rows = new ArrayList<String>(); + Scanner sc = new Scanner(System.in); - while(row.length()>0) { - Integer whiteChar = row.toString().indexOf(" "); - - int rowCount = Integer.valueOf(row.substring(0, whiteChar)); - String text = row.substring(whiteChar+1, row.length()); - + + while (sc.hasNext()) { + int rowCount = sc.nextInt(); + String text = sc.nextLine().trim(); - for (int i = 0; i < rowCount; i++) { - String row2 = br.readLine(); + String row2 = sc.nextLine(); String tmp = row2.replace(text, ""); - rows.add(tmp); + System.out.println(tmp); } - row = new StringBuffer(br.readLine()); - } - - for (String r : rows) { - System.out.println(r); }