Source code for submission s934

Go to diff to previous submission

Bugs.java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package bugs;
  6.  
  7.  
  8. import java.io.BufferedReader;
  9. import java.io.IOException;
  10. import java.io.InputStreamReader;
  11. import java.util.ArrayList;
  12.  
  13. /**
  14.  *
  15.  * @author student
  16.  */
  17. public class Bugs {
  18.  
  19. /**
  20.   * @param args the command line arguments
  21.   */
  22. public static void main(String[] args) throws IOException {
  23. StringBuffer row = new StringBuffer(br.readLine());
  24.  
  25. ArrayList<String> rows = new ArrayList<String>();
  26.  
  27. while(row.length()>0) {
  28. String[] split = row.toString().split(" ");
  29. int rowCount = Integer.valueOf(split[0]);
  30. String text = split[1];
  31.  
  32. for (int i = 0; i < rowCount; i++) {
  33. String row2 = br.readLine();
  34. String tmp = row2.replace(text, "");
  35. rows.add(tmp);
  36. }
  37. row = new StringBuffer(br.readLine());
  38. }
  39.  
  40. for (String r : rows) {
  41. System.out.println(r);
  42. }
  43.  
  44. }
  45. }
  46.  

Diff to submission s914

Bugs.java

--- c4.s914.cteam124.bugs.java.0.Bugs.java
+++ c4.s934.cteam124.bugs.java.0.Bugs.java
@@ -22,10 +22,10 @@
     public static void main(String[] args) throws IOException {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
-        String row = br.readLine();
+        StringBuffer row = new StringBuffer(br.readLine());
     
         ArrayList<String> rows = new ArrayList<String>();   
-        
-        while(!row.equals("")) {
-            String[] split = row.split(" ");
+
+        while(row.length()>0) {
+            String[] split = row.toString().split(" ");
             int rowCount = Integer.valueOf(split[0]);
             String text = split[1];
@@ -36,5 +36,5 @@
                 rows.add(tmp);
             }
-            row = br.readLine();
+            row = new StringBuffer(br.readLine());
         }