Go to diff to previous submission
import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; /** * * @author cteam049 */ public class bugs { /** * @param args the command line arguments */ { bugs program = new bugs(); program.run(); } protected void run() { try { for ( ;; ) { int lines = this.nextInt(); // String tmp = this.nextLine(); StringBuffer line; int pos; int len = replacement.length(); for ( int i = 0; i < lines; i++ ) { // line = this.nextLine(); while ( ( pos = line.indexOf( replacement ) ) != -1 ) { // System.out.println( pos + " " + len ); line.delete( pos, pos + len ); } } } { e.printStackTrace(); } } /* INPUT READING */ { while ( ! st.hasMoreTokens() ) { } return st.nextToken(); } { } { return input.readLine(); } }
--- c4.s582.cteam049.bugs.java.0.bugs.java +++ c4.s585.cteam049.bugs.java.0.bugs.java @@ -28,5 +28,5 @@ String replacement = this.nextToken(); // String tmp = this.nextLine(); - StringBuilder line; + StringBuffer line; int pos; int len = replacement.length(); @@ -34,10 +34,10 @@ for ( int i = 0; i < lines; i++ ) { - line = new StringBuilder( this.nextLine() ); + line = new StringBuffer( this.nextLine() ); // line = this.nextLine(); while ( ( pos = line.indexOf( replacement ) ) != -1 ) { // System.out.println( pos + " " + len ); - line = line.delete( pos, pos + len ); + line.delete( pos, pos + len ); }