Source code for submission s1133

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 com.sun.rowset.internal.Row;
  9. import java.io.BufferedReader;
  10. import java.io.IOException;
  11. import java.io.InputStreamReader;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import java.util.Scanner;
  15. import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
  16.  
  17. /**
  18.  *
  19.  * @author student
  20.  */
  21. public class Bugs {
  22.  
  23. /**
  24.   * @param args the command line arguments
  25.   */
  26. public static void main(String[] args) throws IOException {
  27. Scanner sc = new Scanner(System.in);
  28. List<String> result = new ArrayList<String>();
  29.  
  30.  
  31.  
  32. String line = br.readLine();
  33.  
  34.  
  35. while (line.length() > 0) {
  36. Scanner s = new Scanner(line);
  37. int rowCount = s.nextInt();
  38. String text = s.nextLine().trim();
  39.  
  40.  
  41. for (int i = 0; i < rowCount; i++) {
  42. String row2 = br.readLine();
  43. String tmp = row2.replace(text, "");
  44. result.add(tmp);
  45. //System.out.println(tmp);
  46. }
  47.  
  48. // String row = sc.nextLine();
  49. // if (row.length() ==0) break;
  50.  
  51.  
  52. line = br.readLine();
  53.  
  54. }
  55. for (String string : result) {
  56. System.out.println(string);
  57. }
  58. }
  59. }
  60.  

Diff to submission s1109

Bugs.java

--- c4.s1109.cteam124.bugs.java.0.Bugs.java
+++ c4.s1133.cteam124.bugs.java.0.Bugs.java
@@ -30,11 +30,16 @@
         
        
-        while (sc.hasNextInt()) {            
-            int rowCount = sc.nextInt();
-            String text = sc.nextLine().trim();
+        BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));
+        String line = br.readLine();
+        
+        
+        while (line.length() > 0) {     
+            Scanner s = new Scanner(line);
+            int rowCount = s.nextInt();
+            String text = s.nextLine().trim();
             
             
             for (int i = 0; i < rowCount; i++) {
-                String row2 = sc.nextLine();
+                String row2 = br.readLine();
                 String tmp = row2.replace(text, "");
                 result.add(tmp);
@@ -42,7 +47,10 @@
             }
             
-            String row = sc.nextLine();
-            if (row.length() ==0) break;
+//            String row = sc.nextLine();
+//            if (row.length() ==0) break;
+            
             
+            line = br.readLine();
+                    
         }
         for (String string : result) {