Source code for submission s1063

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. import java.util.List;
  13. import java.util.Scanner;
  14. import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
  15.  
  16. /**
  17.  *
  18.  * @author student
  19.  */
  20. public class Bugs {
  21.  
  22. /**
  23.   * @param args the command line arguments
  24.   */
  25. public static void main(String[] args) throws IOException {
  26. Scanner sc = new Scanner(System.in);
  27.  
  28. while (sc.hasNextInt()) {
  29. int rowCount = sc.nextInt();
  30. String text = sc.nextLine().trim();
  31. List<String> result = new ArrayList<String>();
  32.  
  33. for (int i = 0; i < rowCount; i++) {
  34. String row2 = sc.nextLine();
  35. String tmp = row2.replace(text, "");
  36. result.add(tmp);
  37. //System.out.println(tmp);
  38. }
  39.  
  40. for (String string : result) {
  41. System.out.println(string);
  42. }
  43. }
  44. }
  45. }
  46.  

Diff to submission s1046

Bugs.java

--- c4.s1046.cteam124.bugs.java.0.Bugs.java
+++ c4.s1063.cteam124.bugs.java.0.Bugs.java
@@ -10,4 +10,5 @@
 import java.io.InputStreamReader;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Scanner;
 import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
@@ -24,17 +25,21 @@
     public static void main(String[] args) throws IOException {
         Scanner sc = new Scanner(System.in);
-
         
-        while (sc.hasNext()) {            
+        while (sc.hasNextInt()) {            
             int rowCount = sc.nextInt();
             String text = sc.nextLine().trim();
+            List<String> result = new ArrayList<String>();
             
             for (int i = 0; i < rowCount; i++) {
                 String row2 = sc.nextLine();
                 String tmp = row2.replace(text, "");
-                System.out.println(tmp);
+                result.add(tmp);
+                //System.out.println(tmp);
+            }
+            
+            for (String string : result) {
+                System.out.println(string);
             }
         }
-        
     }
 }