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.IOException; import java.util.Scanner; /** * * @author cteam064 */ public class Main { byte[]array = new byte[1]; char c; try{ c = (char) array[0]; return c; } return 0; } } int lines; String delimiter; int j = 0; while (scanner.hasNextInt()){ lines = scanner.nextInt(); delimiter = scanner.next(); for (int i = 0; i < lines;i++){ char c = readChar(); while(c != '\n'){ if (delimiter.charAt(0) == c){ buffer += c; while(c != '\n'){ c = readChar(); buffer += c; while (buffer.length() >= delimiter.length() && buffer.substring(buffer.length() - delimiter.length(), buffer.length()).contains(delimiter)){ buffer = buffer.substring(0, buffer.length() - delimiter.length()); } if (buffer.isEmpty()){ break; } } } else{ } c = readChar(); } } } } }
--- c4.s962.cteam064.bugs.java.0.Main.java +++ c4.s996.cteam064.bugs.java.0.Main.java @@ -36,5 +36,5 @@ String buffer = ""; int j = 0; - while (scanner.hasNext()){ + while (scanner.hasNextInt()){ lines = scanner.nextInt(); delimiter = scanner.next(); @@ -47,6 +47,6 @@ c = readChar(); buffer += c; - while (buffer.contains(delimiter)){ - buffer = buffer.replaceAll(delimiter, ""); + while (buffer.length() >= delimiter.length() && buffer.substring(buffer.length() - delimiter.length(), buffer.length()).contains(delimiter)){ + buffer = buffer.substring(0, buffer.length() - delimiter.length()); } if (buffer.isEmpty()){