Source code for submission s1166

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.IOException;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. import java.util.Scanner;
  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. Scanner sc = new Scanner(System.in);
  24. List<String> result = new ArrayList<String>();
  25.  
  26.  
  27.  
  28. //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  29. //String line = br.readLine();
  30.  
  31. Scanner scanner = new Scanner(System.in);
  32. String line = scanner.nextLine();
  33.  
  34. while (line.length() > 0) {
  35. Scanner s = new Scanner(line);
  36. int rowCount = s.nextInt();
  37. String text = s.nextLine().trim();
  38.  
  39.  
  40. for (int i = 0; i < rowCount; i++) {
  41. String row2 = scanner.nextLine();
  42. String tmp = row2.replace(text, "");
  43. result.add(tmp);
  44. }
  45. line = scanner.nextLine();
  46.  
  47. }
  48. for (String string : result) {
  49. System.out.println(string);
  50. }
  51. }
  52. }
  53.  

Diff to submission s1133

Bugs.java

--- c4.s1133.cteam124.bugs.java.0.Bugs.java
+++ c4.s1166.cteam124.bugs.java.0.Bugs.java
@@ -6,12 +6,8 @@
 
 
-import com.sun.rowset.internal.Row;
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Scanner;
-import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
 
 /**
@@ -30,7 +26,9 @@
         
        
-        BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));
-        String line = br.readLine();
+        //BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));
+        //String line = br.readLine();
         
+        Scanner scanner = new Scanner(System.in);
+        String line = scanner.nextLine();
         
         while (line.length() > 0) {     
@@ -38,18 +36,12 @@
             int rowCount = s.nextInt();
             String text = s.nextLine().trim();
-            
+           
             
             for (int i = 0; i < rowCount; i++) {
-                String row2 = br.readLine();
+                String row2 = scanner.nextLine();
                 String tmp = row2.replace(text, "");
                 result.add(tmp);
-                //System.out.println(tmp);
             }
-            
-//            String row = sc.nextLine();
-//            if (row.length() ==0) break;
-            
-            
-            line = br.readLine();
+            line = scanner.nextLine();
                     
         }