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(); StringBuilder line; int pos; int len = replacement.length(); for ( int i = 0; i < lines; i++ ) { line = new StringBuilder( this.nextLine() ); // line = this.nextLine(); while ( ( pos = line.indexOf( replacement ) ) != -1 ) { // System.out.println( pos + " " + len ); line = line.delete( pos, pos + len ); } } } { e.printStackTrace(); } } /* INPUT READING */ { while ( ! st.hasMoreTokens() ) { } return st.nextToken(); } { } { return input.readLine(); } }
--- c4.s573.cteam049.bugs.java.0.bugs.java +++ c4.s582.cteam049.bugs.java.0.bugs.java @@ -28,15 +28,17 @@ String replacement = this.nextToken(); // String tmp = this.nextLine(); - String line; - int oldLen; + StringBuilder line; + int pos; + int len = replacement.length(); for ( int i = 0; i < lines; i++ ) { - line = this.nextLine(); - do + line = new StringBuilder( this.nextLine() ); + // line = this.nextLine(); + while ( ( pos = line.indexOf( replacement ) ) != -1 ) { - oldLen = line.length(); - line = line.replace( replacement, "" ); - } while( oldLen != line.length() ); + // System.out.println( pos + " " + len ); + line = line.delete( pos, pos + len ); + } System.out.println( line );