Source code for submission s909

Go to diff to previous submission

Bugs.java

  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.Scanner;
  5.  
  6. public class Bugs {
  7.  
  8. public static void main(String[] args) throws IOException {
  9.  
  10.  
  11. while (true) {
  12. String vstupRadka = br.readLine();
  13.  
  14. if (vstupRadka == null) {
  15. break;
  16. }
  17.  
  18. Scanner sc = new Scanner(vstupRadka);
  19.  
  20. int n = sc.nextInt();
  21. String slovo = sc.next();
  22.  
  23. for (int i = 0; i < n; i++) {
  24. String radka = br.readLine();
  25.  
  26. if (!radka.contains(slovo)) {
  27. System.out.println(radka);
  28. } else {
  29.  
  30. while (true) {
  31. radka = radka.replace(slovo, "");
  32. if (!radka.contains(slovo)) {
  33. System.out.println(radka);
  34. break;
  35. }
  36.  
  37. }
  38.  
  39.  
  40. }
  41. }
  42. }
  43.  
  44. }
  45.  
  46. }
  47.  

Diff to submission s881

Bugs.java

--- c4.s881.cteam118.bugs.java.0.Bugs.java
+++ c4.s909.cteam118.bugs.java.0.Bugs.java
@@ -28,13 +28,15 @@
                                         System.out.println(radka);
                                 } else {
-                                        String stary = radka;
+                                                                        
                                         while (true) {
-                                                String novy = stary.replace(slovo, "");
-                                                if (novy.equals(stary)) {
-                                                        System.out.println(novy);
+                                                radka = radka.replace(slovo, "");
+                                                if (!radka.contains(slovo)) {
+                                                        System.out.println(radka);
                                                         break;
                                                 }                                               
-                                                stary = novy;                                           
+                                                                
                                         }
+                                        
+                                        
                                 }
                         }